本文整理汇总了Python中naaya.core.zope2util.path_in_site函数的典型用法代码示例。如果您正苦于以下问题:Python path_in_site函数的具体用法?Python path_in_site怎么用?Python path_in_site使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_in_site函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: group_tmpl
def group_tmpl(portal, objs, **kwargs):
keyer = lambda item: path_in_site(item['ob'])
sorted_items = sorted(objs, key=keyer)
items_str = ''.join('[%s]' % path_in_site(item['ob']) for
item in sorted_items)
body = '%s %s %s' % (template_name, items_str,
portal.title_or_id())
return {'subject': 'notifications', 'body_text': body}
开发者ID:pombredanne,项目名称:trunk-eggs,代码行数:8,代码来源:test_notifications_unit.py
示例2: test_walk_subscriptions
def test_walk_subscriptions(self):
subs1 = list((path_in_site(obj), sub) for
obj, n, sub in walk_subscriptions(self.portal))
self.assertEqual(len(subs1), 2)
self.assertTrue(('f1/b/2', self.user2_sub) in subs1)
self.assertTrue(('f1/b', self.user1_sub) in subs1)
subs2 = list((path_in_site(obj), sub) for
obj, n, sub in
walk_subscriptions(self.portal['f1']['b']['2']))
self.assertEqual(len(subs2), 1)
self.assertTrue(('f1/b/2', self.user2_sub) in subs1)
subs3 = list(walk_subscriptions(self.portal['f1']['a']))
self.assertEqual(len(subs3), 0)
开发者ID:eaudeweb,项目名称:Products.Naaya,代码行数:15,代码来源:test_subscription_container.py
示例3: xrjs_getGeoPoints
def xrjs_getGeoPoints(self, REQUEST):
""" """
try:
points = []
for res in self.search_geo_objects(REQUEST=REQUEST):
if res.geo_location is None:
continue
points.append(
{
"lat": res.geo_location.lat,
"lon": res.geo_location.lon,
"id": path_in_site(res),
"label": res.title_or_id(),
"icon_name": "mk_%s" % res.geo_type,
"tooltip": self.get_marker(res),
}
)
json_response = json.dumps({"points": points}, default=json_encode_helper)
except:
self.log_current_error()
json_response = json.dumps({"error": err_info(), "points": {}})
REQUEST.RESPONSE.setHeader("Content-type", "application/json")
return json_response
开发者ID:eaudeweb,项目名称:Products.Naaya,代码行数:26,代码来源:GeoMapTool.py
示例4: handle_edit_content
def handle_edit_content(event):
"""
Test whether this requires adding pointers and perform the action
"""
obj = event.context
site = obj.getSite()
if not getattr(site, 'destinet.publisher', False):
return None
q_both = _qualifies_for_both(obj)
q_topics = _qualifies_for_topics_only(obj)
if q_topics or q_both:
# clean-up all existing pointers, then re-add them
cat = site.getCatalogTool()
pointers = cat.search({'meta_type': 'Naaya Pointer',
'path': [ofs_path(site.countries),
ofs_path(site.topics),
ofs_path(getattr(site, 'resources')),
# kept for pointers prior to v 1.1
ofs_path(getattr(site, 'who-who'))],
'pointer': path_in_site(obj)})
for brain in pointers:
pointer = brain.getObject()
pointer.aq_parent._delObject(pointer.id)
if q_both:
place_pointers(obj)
else:
place_pointers(obj, exclude=['target-groups'])
开发者ID:pombredanne,项目名称:trunk-eggs,代码行数:28,代码来源:subscribers.py
示例5: saved_emails
def saved_emails(self, REQUEST=None, RESPONSE=None):
""" Display all saved bulk emails """
emails = get_bulk_emails(self.getSite(),
where_to_read=path_in_site(self.getMeeting()))
import_non_local('email', 'std_email')
from std_email import email as standard_email
for email in emails:
subject, encoding = standard_email.Header.decode_header(
email['subject'])[0]
if encoding:
email['subject'] = subject.decode(encoding)
else:
email['subject'] = subject
recipients = []
if email['recipients'] is None:
email['recipients'] = []
for recp in email['recipients']:
recipients.extend(re.split(',|;', recp.replace(' ', '')))
email['recipients'] = recipients
cc_recipients = []
if email['cc_recipients'] is None:
email['cc_recipients'] = []
for recp in email['cc_recipients']:
cc_recipients.extend(re.split(',|;', recp.replace(' ', '')))
email['cc_recipients'] = cc_recipients
return self.getFormsTool().getContent(
{'here': self,
'emails': emails,
'meeting': self.getMeeting()},
'naaya.content.meeting.email_archive')
开发者ID:eaudeweb,项目名称:naaya.content.meeting,代码行数:30,代码来源:email.py
示例6: xrjs_getGeoPoints
def xrjs_getGeoPoints(self, REQUEST):
""" """
try:
points = []
for res in self.search_geo_objects(REQUEST=REQUEST):
if res.geo_location is None:
continue
points.append({
'lat': res.geo_location.lat,
'lon': res.geo_location.lon,
'id': path_in_site(res),
'label': res.title_or_id(),
'icon_name': 'mk_%s' % res.geo_type,
'tooltip': self.get_marker(res),
})
json_response = json.dumps({'points': points},
default=json_encode_helper)
except:
self.log_current_error()
json_response = json.dumps({'error': err_info(), 'points': {}})
REQUEST.RESPONSE.setHeader('Content-type', 'application/json')
return json_response
开发者ID:eaudeweb,项目名称:Naaya-legacy,代码行数:25,代码来源:GeoMapTool.py
示例7: send_notifications_for_event
def send_notifications_for_event(event, subscriber_data_default, template):
"""Send notifications to site maintainers and subscribers. Create event
handler must be supressed when this action is run.
"""
folder = event.context
portal = folder.getSite()
notification_tool = portal.getNotificationTool()
action_logger = portal.getActionLogger()
subscribers_data = {}
maintainers_data = {}
#Get maintainers
maintainers = portal.getMaintainersEmails(folder)
for email in maintainers:
data = dict(subscriber_data_default)
data.update({
'ob': folder,
'here': notification_tool,
})
maintainers_data[email] = data
#Get subscribers
if notification_tool.config['enable_instant'] is True:
subscribers_data = utils.get_subscribers_data(notification_tool,
folder, **subscriber_data_default)
subscribers_data.update(maintainers_data)
notification_tool._send_notifications(subscribers_data,
template.render_email)
#Create log entry
action_logger.create(type=constants.LOG_TYPES['bulk_import'],
path=path_in_site(folder))
开发者ID:pombredanne,项目名称:trunk-eggs,代码行数:35,代码来源:subscribers.py
示例8: _update
def _update(self, portal):
notif_tool = portal.getNotificationTool()
auth_tool = portal.getAuthenticationTool()
admins = auth_tool.search_users('', role='Administrator',
rkey=0, skey='name', all_users=True, location='_all_')
self.log.debug('Started update in %s' % portal.getId())
for admin in admins:
for role in admin.roles:
if 'Administrator' in role[0]:
user_id = admin.user_id
own_site_location = path_in_site(role[1])
this_site_location = relative_object_path(role[1], portal)
if own_site_location != this_site_location:
self.log.debug('Location %s is probably in a subportal'
% own_site_location)
continue
obj = portal.restrictedTraverse(this_site_location)
if match_account_subscription(
ISubscriptionContainer(obj), user_id, 'administrative', 'en'):
self.log.debug('Subscription for user %s already present '
'in location %s' %(user_id, this_site_location or '/'))
else:
notif_tool.add_account_subscription(user_id,
this_site_location, 'administrative', 'en', [])
self.log.debug('Subscription added for user %s in location %s'
%(user_id, this_site_location or '/'))
return True
开发者ID:eaudeweb,项目名称:Products.Naaya,代码行数:27,代码来源:updates.py
示例9: url_entry
def url_entry(self, parent_path, ob_id, filename, url,
title, description, keywords, date, userid):
parent = get_parent(self.context, parent_path)
orig_path = join_parent_path(parent_path, ob_id)
assert orig_path not in self.rename
kwargs = {
'id': ob_id,
'contributor': userid or self.default_userid,
'releasedate': nydateformat(date),
'title': title,
'description': description,
'keywords': keywords,
'locator': url,
'_send_notifications': False,
}
url_id = addNyURL(parent, **kwargs)
if parent_path:
self.rename[orig_path] = parent_path + '/' + url_id
else:
self.rename[orig_path] = url_id
new_url = parent[url_id]
logger.info("Added url: %r", path_in_site(new_url))
self.count['urls'] += 1
开发者ID:mihneasim,项目名称:edw.circaimport,代码行数:25,代码来源:actors.py
示例10: test_contact_with_group
def test_contact_with_group(self):
""" test destinet registration when group is selected """
self.portal.REQUEST.form.update(self.initial_data)
self.portal.REQUEST.form.update(groups=['test-group'])
process_create_account(self.context, self.portal.REQUEST)
contact = self.portal['who-who']['destinet-users'].objectValues()[0]
pointer = self.portal.resources._getOb(contact.getId())
self.assertEqual(pointer.pointer, path_in_site(contact))
开发者ID:eaudeweb,项目名称:naaya.destinet.extra,代码行数:8,代码来源:tests.py
示例11: view_email
def view_email(self, filename, REQUEST=None, RESPONSE=None):
""" Display a specfic saved email """
email = get_bulk_email(self.getSite(), filename,
where_to_read=path_in_site(self.getMeeting()))
return self.getFormsTool().getContent(
{'here': self,
'email': email,
'meeting': self.getMeeting()},
'naaya.content.meeting.email_view_email')
开发者ID:eaudeweb,项目名称:naaya.content.meeting,代码行数:9,代码来源:email.py
示例12: view_email
def view_email(self, filename, REQUEST=None, RESPONSE=None):
""" Display a specfic saved email """
email = get_bulk_email(self.getSite(), filename,
where_to_read=path_in_site(
self.get_consultation()))
return self.getFormsTool().getContent(
{'here': self, 'email': email,
'consultation': self.get_consultation()},
'tb_consultation-view_email')
开发者ID:eaudeweb,项目名称:naaya.content.talkback,代码行数:9,代码来源:invitations.py
示例13: send_email
def send_email(self, REQUEST):
""" Send e-mail """
keys = ('to', 'cc', 'subject', 'message')
formerrors = {}
if REQUEST.REQUEST_METHOD == 'POST':
formdata = dict((key, REQUEST.form.get(key, '')) for key in keys)
email_tool = self.getEmailTool()
acl_tool = self.getAuthenticationTool()
emails_to = []
emails_cc = []
to = formdata['to']
cc = formdata['cc']
message = formdata['message']
if not to:
formerrors['to'] = 'At least one recipinet is needed'
if not formdata['subject']:
formerrors['subject'] = 'Email subject is mandatory'
if not message:
formerrors['message'] = 'Message body is mandatory'
if not formerrors:
for item in to:
if '@' in item:
emails_to.append(item.strip())
else:
user_info = acl_tool.get_user_info(item.strip())
emails_to.append(user_info.email)
for item in cc:
if '@' in item:
emails_cc.append(item.strip())
else:
user_info = acl_tool.get_user_info(item.strip())
emails_cc.append(user_info.email)
email_tool.sendEmail(formdata['message'],
emails_to,
email_tool.get_addr_from(),
formdata['subject'], p_cc=emails_cc)
save_bulk_email(self.getSite(), emails_to,
email_tool.get_addr_from(),
formdata['subject'], formdata['message'],
where_to_save=path_in_site(
self.get_consultation()),
addr_cc=emails_cc)
self.setSessionInfoTrans('Email sent to %s and in CC to %s.' %
(','.join(emails_to),
','.join(emails_cc)))
return REQUEST.RESPONSE.redirect(self.absolute_url() +
'/send_email')
else:
self.setSessionErrorsTrans('The form contains errors. Please '
'correct them and try again.')
else:
formdata = dict((key, '') for key in keys)
return self._create_email_html(formdata=formdata,
formerrors=formerrors)
开发者ID:eaudeweb,项目名称:naaya.content.talkback,代码行数:57,代码来源:invitations.py
示例14: saved_emails
def saved_emails(self, REQUEST=None, RESPONSE=None):
""" Display all saved invitation emails """
emails = get_bulk_emails(self.getSite(),
where_to_read=path_in_site(
self.get_consultation()))
return self.getFormsTool().getContent(
{'here': self, 'emails': emails,
'consultation': self.get_consultation()},
'tbconsultation-email_archive')
开发者ID:eaudeweb,项目名称:naaya.content.talkback,代码行数:9,代码来源:invitations.py
示例15: __call__
def __call__(self, context, position):
notif_tool = self.site.getNotificationTool()
if not list(notif_tool.available_notif_types()):
return ''
macro = self.site.getPortletsTool()._get_macro(position)
tmpl = self.template.__of__(context)
return tmpl(macro=macro, notif_tool=notif_tool,
location=path_in_site(context))
开发者ID:pombredanne,项目名称:trunk-eggs,代码行数:9,代码来源:portlets.py
示例16: change_user_roles
def change_user_roles(event):
"""Update subscriptions when a user's roles were updated:
If he now gets the Administrator role, he should be subscribed
to administrative notifications. If he loses the role, his subscription
should be revoked"""
notif_tool = event.context.getNotificationTool()
portal = event.context.getSite()
if "Administrator" in event.assigned:
if not utils.match_account_subscription(
ISubscriptionContainer(event.context), event.user_id, "administrative", "en"
):
notif_tool.add_account_subscription(event.user_id, path_in_site(event.context), "administrative", "en", [])
if "Administrator" in event.unassigned:
if utils.match_account_subscription(
ISubscriptionContainer(event.context), event.user_id, "administrative", "en"
):
notif_tool.remove_account_subscription(event.user_id, path_in_site(event.context), "administrative", "en")
开发者ID:eaudeweb,项目名称:Products.Naaya,代码行数:18,代码来源:subscribers.py
示例17: send_email
def send_email(self, from_email, subject, body_text, cc_emails, REQUEST,
to_uids=None):
""" """
errors = []
if not to_uids:
to_uids = []
if not (to_uids or cc_emails):
errors.append('Please select at least on recipient')
if not (subject or body_text):
errors.append('Subject and message body cannot both be empty')
for email in cc_emails:
if not is_valid_email(email):
errors.append('Invalid email "%s" in CC field' % email)
if errors:
self.setSessionErrorsTrans(errors)
return REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER)
participants = self.getParticipants()
subscriptions = participants.getSubscriptions()
signup_emails = [participants.getAttendeeInfo(uid)['email']
for uid in to_uids if
subscriptions._is_signup(uid)]
account_emails = [participants.getAttendeeInfo(uid)['email']
for uid in to_uids if not
subscriptions._is_signup(uid)]
to_emails = signup_emails + account_emails
if (self.eionet_meeting() and
'[email protected]' not in cc_emails):
cc_emails.append('[email protected]')
# TODO validate cc_emails
# We need to send the emails to signups one by one since each email
# might be different (if they contain links to documents for
# which the authentication keys is inserted into the link)
for uid in to_uids:
if subscriptions._is_signup(uid):
signup_email = participants.getAttendeeInfo(uid)['email']
signup_body_text = self.insert_auth_link(body_text, uid)
result = self._send_email(
from_email, [signup_email], cc_emails, subject,
signup_body_text, only_to=True)
if account_emails:
result = self._send_email(from_email, account_emails, cc_emails,
subject, body_text)
save_bulk_email(self.getSite(), to_emails, from_email, subject,
body_text,
where_to_save=path_in_site(self.getMeeting()),
addr_cc=cc_emails)
return self.getFormsTool().getContent(
{'here': self,
'meeting': self.getMeeting(),
'result': result},
'naaya.content.meeting.email_sendstatus')
开发者ID:eaudeweb,项目名称:naaya.content.meeting,代码行数:56,代码来源:email.py
示例18: mail_in_queue
def mail_in_queue(self, filename):
""" Check if a specific message is still in queue """
COMMON_KEYS = ['sender', 'recipients', 'subject', 'content', 'date']
check_values = {}
archived_email = get_bulk_email(self.getSite(), filename,
where_to_read=path_in_site(
self.get_consultation()))
for key in COMMON_KEYS:
check_values[key] = archived_email[key]
return _mail_in_queue(self.getSite(), filename, check_values)
开发者ID:eaudeweb,项目名称:naaya.content.talkback,代码行数:10,代码来源:invitations.py
示例19: handle_forum_object_add
def handle_forum_object_add(event):
obj = event.context
portal = obj.getSite()
contributor = event.contributor
notification_tool = portal.getNotificationTool()
notification_tool.notify_instant(obj, contributor)
if obj.approved: #Create log entry
action_logger = portal.getActionLogger()
action_logger.create(type=LOG_TYPES['created'],
contributor=contributor, path=path_in_site(obj))
开发者ID:eaudeweb,项目名称:naaya.Products.NaayaForum,代码行数:11,代码来源:subscribers.py
示例20: mail_in_queue
def mail_in_queue(self, filename):
""" Check if a specific message is still in queue """
# removed recipients from COMMON_KEYS because of signup
# recipients splitting
COMMON_KEYS = ['sender', 'subject', 'content', 'date']
check_values = {}
archived_email = get_bulk_email(
self.getSite(), filename,
where_to_read=path_in_site(self.getMeeting()))
for key in COMMON_KEYS:
check_values[key] = archived_email[key]
return _mail_in_queue(self.getSite(), filename, check_values)
开发者ID:eaudeweb,项目名称:naaya.content.meeting,代码行数:12,代码来源:email.py
注:本文中的naaya.core.zope2util.path_in_site函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论