Reordered functions
authorThierry Florac <tflorac@ulthar.net>
Thu, 08 Feb 2018 08:50:04 +0100
changeset 135 fc98621aa9d2
parent 134 73c01f34ef19
child 136 e5a7e65ba12a
Reordered functions
src/pyams_utils/registry.py
--- a/src/pyams_utils/registry.py	Mon Feb 05 13:53:51 2018 +0100
+++ b/src/pyams_utils/registry.py	Thu Feb 08 08:50:04 2018 +0100
@@ -10,7 +10,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
-__doc__ = """Local registry management package
+__doc__ = """Registry management package
 
 This package is used to manage *local registry*. A local registry is a *site management* component
 created automatically on application startup by PyAMS_utils package. It can be used to store and register
@@ -45,7 +45,11 @@
 
 
 class LocalRegistry(threading.local):
-    """Local registry"""
+    """Local registry
+
+    The local registry is defined to allow access to persistent utility
+    registered and stored into ZODB.
+    """
 
     _registry = None
 
@@ -59,7 +63,10 @@
 
 
 def get_local_registry():
-    """Get local registry"""
+    """Get local registry
+
+    Local registry is automatically defined while traversing a site manager.
+    """
     return local_registry.get_registry()
 
 
@@ -101,19 +108,23 @@
             yield registry
 
 
-def get_current_registry(context=None):
-    """Get current or global registry"""
-    registry = get_request_registry(context)
-    if registry is None:
-        registry = getGlobalSiteManager()
-    return registry
-
-
 def get_global_registry():
     """Get global registry"""
     return getGlobalSiteManager()
 
 
+def get_current_registry(context=None):
+    """Get current or global registry
+
+    The function is looking for given request registry.
+    If registry is None, returns the global registry.
+    """
+    registry = get_request_registry(context)
+    if registry is None:
+        registry = get_global_registry()
+    return registry
+
+
 def registered_utilities():
     """Get utilities registrations as generator
 
@@ -193,7 +204,11 @@
     :param str name: default=''; name under which the utility is registered
     :param Interface provides: the interface for which the utility is registered
 
-    Please note that a single utility can be registered several times (using several annotations).
+    Please note that a single utility can be registered several times (using several annotations), with
+    different names.
+
+    If several utilities are registered for the same interface with the same name, the last registered
+    utility will override the previous ones.
     """
 
     venusian = venusian