def user_page_view(context, request): if request.has_permission('view_details'): properties = item_view_object(context, request) else: item_path = request.resource_path(context) properties = request.embed(item_path, '@@object') for path in context.embedded: expand_path(request, properties, path) calculated = calculate_properties(context, request, properties, category='page') properties.update(calculated) return properties
def session_properties(request): for principal in request.effective_principals: if principal.startswith('userid.'): break else: return {} namespace, userid = principal.split('.', 1) user = request.registry[COLLECTIONS]['user'][userid] user_actions = calculate_properties(user, request, category='user_action') properties = { 'user': request.embed(request.resource_path(user)), 'user_actions': [v for k, v in sorted(user_actions.items(), key=itemgetter(0))] } if 'auth.userid' in request.session: properties['auth.userid'] = request.session['auth.userid'] return properties