本文整理汇总了Python中naaya.core.zope2util.path_in_site函数的典型用法代码示例。如果您正苦于以下问题:Python path_in_site函数的具体用法?Python path_in_site怎么用?Python path_in_site使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了path_in_site函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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}
示例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)
示例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
示例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'])
示例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')
示例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
示例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))
示例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
示例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
示例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))
示例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')
示例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')
示例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)
示例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')
示例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))