src/pyams_security/profile.py
changeset 69 5026082a5aa1
parent 64 59d37fc75008
child 93 be0b2504aaf3
equal deleted inserted replaced
68:6302ba59d8ea 69:5026082a5aa1
    17 
    17 
    18 # import interfaces
    18 # import interfaces
    19 from pyams_security.interfaces import IPrincipalInfo
    19 from pyams_security.interfaces import IPrincipalInfo
    20 from pyams_security.interfaces.profile import PUBLIC_PROFILE_KEY, IPublicProfile
    20 from pyams_security.interfaces.profile import PUBLIC_PROFILE_KEY, IPublicProfile
    21 from pyams_utils.interfaces import PUBLIC_PERMISSION
    21 from pyams_utils.interfaces import PUBLIC_PERMISSION
    22 from pyams_utils.interfaces.site import ISiteRoot
       
    23 from pyams_utils.interfaces.tales import ITALESExtension
    22 from pyams_utils.interfaces.tales import ITALESExtension
    24 from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
    23 from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
    25 from zope.intid.interfaces import IIntIds
    24 from zope.intid.interfaces import IIntIds
    26 from zope.traversing.interfaces import ITraversable
    25 from zope.traversing.interfaces import ITraversable
    27 
    26 
    29 from persistent import Persistent
    28 from persistent import Persistent
    30 from pyams_file.property import FileProperty
    29 from pyams_file.property import FileProperty
    31 from pyams_utils.adapter import adapter_config, ContextRequestAdapter
    30 from pyams_utils.adapter import adapter_config, ContextRequestAdapter
    32 from pyams_utils.registry import get_utility
    31 from pyams_utils.registry import get_utility
    33 from pyams_utils.request import check_request, query_request
    32 from pyams_utils.request import check_request, query_request
    34 from pyams_utils.traversing import get_parent
       
    35 from pyramid.security import Allow, ALL_PERMISSIONS, Everyone
    33 from pyramid.security import Allow, ALL_PERMISSIONS, Everyone
    36 from pyramid.threadlocal import get_current_registry, get_current_request
    34 from pyramid.threadlocal import get_current_registry, get_current_request
    37 from zope.container.contained import Contained
    35 from zope.container.contained import Contained
    38 from zope.lifecycleevent import ObjectCreatedEvent
    36 from zope.lifecycleevent import ObjectCreatedEvent
    39 from zope.interface import implementer, Interface
    37 from zope.interface import implementer, Interface
    69     if profile is None:
    67     if profile is None:
    70         profile = annotations[PUBLIC_PROFILE_KEY] = PublicProfile()
    68         profile = annotations[PUBLIC_PROFILE_KEY] = PublicProfile()
    71         get_current_registry().notify(ObjectCreatedEvent(profile))
    69         get_current_registry().notify(ObjectCreatedEvent(profile))
    72         request = get_current_request()
    70         request = get_current_request()
    73         if request is not None:
    71         if request is not None:
    74             root = get_parent(request.context, ISiteRoot)
    72             root = request.root
    75             intids = get_utility(IIntIds)
    73             intids = get_utility(IIntIds)
    76             locate(profile, root)  # avoid NotYet exception
    74             locate(profile, root)  # avoid NotYet exception
    77             locate(profile, root, '++profile++{0}'.format(intids.register(profile)))
    75             locate(profile, root, '++profile++{0}'.format(intids.register(profile)))
    78     return profile
    76     return profile
    79 
    77