Updated global registry access
authorThierry Florac <tflorac@ulthar.net>
Thu, 08 Feb 2018 08:52:49 +0100
changeset 44 84d2932b293f
parent 43 b1adb0a58354
child 45 f503181e8b77
Updated global registry access
src/pyams_content_es/include.py
src/pyams_content_es/process.py
src/pyams_content_es/utility.py
--- a/src/pyams_content_es/include.py	Fri Jan 26 17:23:06 2018 +0100
+++ b/src/pyams_content_es/include.py	Thu Feb 08 08:52:49 2018 +0100
@@ -26,10 +26,10 @@
 
 # import packages
 from pyams_content_es.process import ContentIndexerProcess, ContentIndexerMessageHandler
+from pyams_utils.registry import get_global_registry
 from pyams_zmq.process import process_exit_func
 from pyramid.events import subscriber
 from pyramid.settings import asbool
-from zope.component.globalregistry import getGlobalSiteManager
 
 
 def include_package(config):
@@ -55,7 +55,7 @@
     if sys.argv[0].endswith('pyams_upgrade'):
         return
 
-    registry = getGlobalSiteManager()
+    registry = get_global_registry()
     settings = registry.settings
     start_handler = asbool(settings.get(INDEXER_STARTER_KEY, False))
     if start_handler:
--- a/src/pyams_content_es/process.py	Fri Jan 26 17:23:06 2018 +0100
+++ b/src/pyams_content_es/process.py	Thu Feb 08 08:52:49 2018 +0100
@@ -28,12 +28,11 @@
 from zope.intid.interfaces import IIntIds
 
 # import packages
-from pyams_utils.registry import set_local_registry, get_utility
+from pyams_utils.registry import set_local_registry, get_utility, get_global_registry
 from pyams_utils.zodb import ZODBConnection
 from pyams_zmq.handler import ZMQMessageHandler
 from pyams_zmq.process import ZMQProcess
 from pyramid.threadlocal import manager as threadlocal_manager
-from zope.component.globalregistry import getGlobalSiteManager
 
 
 class BaseIndexerProcess(Process):
@@ -46,7 +45,7 @@
     def run(self):
         logger.debug("Starting indexer thread...")
         # Loading components registry
-        registry = getGlobalSiteManager()
+        registry = get_global_registry()
         threadlocal_manager.set({'request': None, 'registry': registry})
         logger.debug("Getting global registry: {0!r}".format(registry))
         # Get ES client
@@ -139,7 +138,7 @@
 
     def test(self, settings):
         messages = ['Content indexer process ready to handle requests.', '']
-        registry = getGlobalSiteManager()
+        registry = get_global_registry()
         es_client = getattr(registry, 'pyramid_es_client', None)
         if es_client is None:
             messages.append('WARNING: no ElasticSearch client defined!')
--- a/src/pyams_content_es/utility.py	Fri Jan 26 17:23:06 2018 +0100
+++ b/src/pyams_content_es/utility.py	Thu Feb 08 08:52:49 2018 +0100
@@ -21,9 +21,8 @@
 
 # import packages
 from persistent import Persistent
-from pyams_utils.registry import get_utility
+from pyams_utils.registry import get_utility, get_global_registry
 from pyams_zmq.socket import zmq_socket, zmq_response
-from zope.component.globalregistry import getGlobalSiteManager
 from zope.container.contained import Contained
 from zope.interface import implementer
 from zope.schema.fieldproperty import FieldProperty
@@ -36,7 +35,7 @@
     zodb_name = FieldProperty(IContentIndexerUtility['zodb_name'])
 
     def _get_socket(self):
-        registry = getGlobalSiteManager()
+        registry = get_global_registry()
         handler = registry.settings.get(INDEXER_HANDLER_KEY, False)
         if handler:
             return zmq_socket(handler)