# HG changeset patch # User Thierry Florac # Date 1464877083 -7200 # Node ID 59d37fc75008136cde26ab0093db9b448c30587d # Parent 402858ec5ac9ad08058c4429b0771ec855ae512b Set distinct profile name to correctly get user's avatar diff -r 402858ec5ac9 -r 59d37fc75008 src/pyams_security/profile.py --- a/src/pyams_security/profile.py Thu Jun 02 16:17:08 2016 +0200 +++ b/src/pyams_security/profile.py Thu Jun 02 16:18:03 2016 +0200 @@ -22,12 +22,14 @@ from pyams_utils.interfaces.site import ISiteRoot from pyams_utils.interfaces.tales import ITALESExtension from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable +from zope.intid.interfaces import IIntIds from zope.traversing.interfaces import ITraversable # import packages from persistent import Persistent from pyams_file.property import FileProperty from pyams_utils.adapter import adapter_config, ContextRequestAdapter +from pyams_utils.registry import get_utility from pyams_utils.request import check_request, query_request from pyams_utils.traversing import get_parent from pyramid.security import Allow, ALL_PERMISSIONS, Everyone @@ -70,7 +72,9 @@ request = get_current_request() if request is not None: root = get_parent(request.context, ISiteRoot) - locate(profile, root, '++profile++') + intids = get_utility(IIntIds) + locate(profile, root) # avoid NotYet exception + locate(profile, root, '++profile++{0}'.format(intids.register(profile))) return profile @@ -79,7 +83,12 @@ """++profile++ namespace traverser""" def traverse(self, name, furtherpath=None): - return IPublicProfile(self.request) + if not name: + return IPublicProfile(self.request.principal) + else: + intids = get_utility(IIntIds) + profile = intids.queryObject(int(name)) + return IPublicProfile(profile, None) @adapter_config(name='public_profile', context=(Interface, Interface), provides=ITALESExtension)