Changed registry access
authorThierry Florac <thierry.florac@onf.fr>
Wed, 20 May 2015 12:30:55 +0200
changeset 39 51a07039228f
parent 38 cadf156a926e
child 40 5ff311e24fdf
Changed registry access
src/pyams_security/security.py
--- a/src/pyams_security/security.py	Wed May 20 12:30:17 2015 +0200
+++ b/src/pyams_security/security.py	Wed May 20 12:30:55 2015 +0200
@@ -30,6 +30,8 @@
 from pyams_utils.request import check_request
 from pyramid.location import lineage
 from pyramid.security import DENY_ALL, Everyone, Allow, ALL_PERMISSIONS, Authenticated
+from pyramid.threadlocal import get_current_registry
+from zope.container.contained import Contained
 from zope.interface import implementer
 from zope.lifecycleevent import ObjectCreatedEvent
 from zope.location.location import locate
@@ -37,7 +39,7 @@
 
 
 @implementer(IRoleProtectedObject)
-class RoleProtectedObject(Persistent):
+class RoleProtectedObject(Persistent, Contained):
     """Base class for object protected by roles"""
 
     inherit_parent_security = FieldProperty(IRoleProtectedObject['inherit_parent_security'])
@@ -176,7 +178,7 @@
     protection = annotations.get(ROLES_ANNOTATIONS_KEY)
     if protection is None:
         protection = annotations[ROLES_ANNOTATIONS_KEY] = RoleProtectedObject()
-        check_request().registry.notify(ObjectCreatedEvent(protection))
+        get_current_registry().notify(ObjectCreatedEvent(protection))
         locate(protection, context)
     return protection