--- 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