Moved site traverse event subscriber to registry module
authorThierry Florac <tflorac@ulthar.net>
Sat, 14 Mar 2015 13:50:21 +0100
changeset 22 e51d9ae05145
parent 21 b1b92e017581
child 23 53a3bfbe6e41
Moved site traverse event subscriber to registry module
src/pyams_utils/site.py
--- a/src/pyams_utils/site.py	Sat Mar 14 13:49:25 2015 +0100
+++ b/src/pyams_utils/site.py	Sat Mar 14 13:50:21 2015 +0100
@@ -21,18 +21,17 @@
 from pyams_utils.interfaces.site import ISiteRoot, INewLocalSiteCreatedEvent, ISiteUpgradeEvent, ISiteGenerations, \
     SITE_GENERATIONS_KEY, IConfigurationManager
 from zope.annotation.interfaces import IAnnotations
-from zope.component.interfaces import IPossibleSite, ISite, ObjectEvent
-from zope.traversing.interfaces import IBeforeTraverseEvent, ITraversable
+from zope.component.interfaces import IPossibleSite, ObjectEvent
+from zope.traversing.interfaces import ITraversable
 
 # import packages
 from persistent.dict import PersistentDict
 from pyams_utils.adapter import adapter_config, ContextAdapter
 from pyams_utils.registry import get_utilities_for, query_utility
-from pyramid.events import subscriber
 from pyramid.exceptions import NotFound
 from pyramid.path import DottedNameResolver
 from pyramid.security import Allow, ALL_PERMISSIONS
-from pyramid.threadlocal import manager, get_current_registry
+from pyramid.threadlocal import get_current_registry
 from pyramid_zodbconn import get_connection
 from zope.container.folder import Folder
 from zope.interface import implementer
@@ -132,16 +131,6 @@
     return application
 
 
-@subscriber(IBeforeTraverseEvent, context_selector=ISite)
-def handle_site_before_traverse(event):
-    """Push registry and request to threadlocal manager when an
-    object implementing ISite is traversed
-    """
-    manager.push({'registry': event.object.getSiteManager(),
-                  'request': event.request})
-    hooks.setSite(event.object)
-
-
 def check_required_utilities(site, utilities):
     """Utility function to check for required utilities