Updated global registry access
authorThierry Florac <tflorac@ulthar.net>
Thu, 08 Feb 2018 08:53:54 +0100
changeset 73 93ad8b37b0c5
parent 72 eefd36b2da13
child 74 be2e9a915714
Updated global registry access
src/pyams_media/include.py
src/pyams_media/media.py
src/pyams_media/process.py
--- a/src/pyams_media/include.py	Tue Feb 06 14:00:27 2018 +0100
+++ b/src/pyams_media/include.py	Thu Feb 08 08:53:54 2018 +0100
@@ -27,12 +27,11 @@
 
 # import packages
 from pyams_media.process import MediaConversionProcess, MediaConversionMessageHandler
-from pyams_utils.registry import set_local_registry
+from pyams_utils.registry import set_local_registry, get_global_registry
 from pyams_utils.zodb import get_connection_from_settings
 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):
@@ -58,7 +57,7 @@
     if sys.argv[0].endswith('pyams_upgrade'):
         return
 
-    registry = getGlobalSiteManager()
+    registry = get_global_registry()
     settings = registry.settings
     start_handler = asbool(settings.get(CONVERTER_STARTER_KEY, False))
     if start_handler:
--- a/src/pyams_media/media.py	Tue Feb 06 14:00:27 2018 +0100
+++ b/src/pyams_media/media.py	Thu Feb 08 08:53:54 2018 +0100
@@ -32,9 +32,8 @@
 from pyams_media.ffbase import FFmpeg
 from pyams_media.ffdocument import FFDocument
 from pyams_utils.adapter import adapter_config, ContextAdapter, ContextRequestViewAdapter
-from pyams_utils.registry import query_utility
+from pyams_utils.registry import query_utility, get_global_registry
 from pyramid.events import subscriber
-from zope.component.globalregistry import getGlobalSiteManager
 from zope.container.folder import Folder
 from zope.interface import implementer, alsoProvides, Interface
 from zope.lifecycleevent import ObjectCreatedEvent
@@ -79,7 +78,7 @@
 
     def add_conversion(self, conversion, format, extension=None, width=None):
         target = FileFactory(conversion)
-        registry = getGlobalSiteManager()
+        registry = get_global_registry()
         registry.notify(ObjectCreatedEvent(target))
         alsoProvides(target, IMediaConversion)
         if extension is None:
--- a/src/pyams_media/process.py	Tue Feb 06 14:00:27 2018 +0100
+++ b/src/pyams_media/process.py	Thu Feb 08 08:53:54 2018 +0100
@@ -30,12 +30,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 ConversionProcess(Process):
@@ -50,7 +49,7 @@
         # Lower process nice...
         os.nice(10)
         # 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))
         # Check settings