--- a/src/pyams_utils/registry.py Fri Nov 10 13:50:06 2017 +0100
+++ b/src/pyams_utils/registry.py Fri Nov 10 13:51:21 2017 +0100
@@ -38,8 +38,9 @@
# import packages
from pyramid.events import subscriber
-from pyramid.threadlocal import manager
+from pyramid.threadlocal import manager, get_current_registry
from ZODB.POSException import POSError
+from zope.component.globalregistry import getGlobalSiteManager
from zope.interface import implementedBy, providedBy
@@ -100,6 +101,14 @@
yield registry
+def get_global_registry(context=None):
+ """Get current or global registry"""
+ registry = get_current_registry(context)
+ if registry is None:
+ registry = getGlobalSiteManager()
+ return registry
+
+
def registered_utilities():
"""Get utilities registrations as generator