rename registration callback, clear argument to register tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 16:57:02 +0100
branchtls-sprint
changeset 668 61b2328f9ed9
parent 667 15fe1d3694d1
child 669 5d2132832f03
rename registration callback, clear argument to register
vregistry.py
--- a/vregistry.py	Tue Feb 17 16:45:22 2009 +0100
+++ b/vregistry.py	Tue Feb 17 16:57:02 2009 +0100
@@ -237,13 +237,20 @@
         return objects[0].selected(*args, **kwargs)
 
     # methods for explicit (un)registration ###################################
-    
-    def register(self, obj, registryname=None, oid=None):
+
+#     def clear(self, key):
+#         regname, oid = key.split('.')
+#         self[regname].pop(oid, None)
+        
+    def register(self, obj, registryname=None, oid=None, clear=False):
         """base method to add an object in the registry"""
         registryname = registryname or obj.__registry__
         oid = oid or obj.id
         registry = self._registries.setdefault(registryname, {})
-        vobjects = registry.setdefault(oid, [])
+        if clear:
+            vobjects = registry[oid] =  []
+        else:
+            vobjects = registry.setdefault(oid, [])
         # registered() is technically a classmethod but is not declared
         # as such because we need to compose registered in some cases
         vobject = obj.registered.im_func(cls, self)
@@ -426,8 +433,8 @@
 
     def load_module(self, module):
         self._registered = {}
-        if hasattr(module, 'cw_register_objects'):
-            module.cw_register_objects(self)
+        if hasattr(module, 'registration_callback'):
+            module.registration_callback(self)
         else:
             self.info('loading %s', module)
             for objname, obj in vars(module).items():