try a register_all method tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 21:42:23 +0100
branchtls-sprint
changeset 695 356da23c57f1
parent 694 520661be60e4
child 696 2a5a19185288
try a register_all method
vregistry.py
--- a/vregistry.py	Tue Feb 17 21:42:06 2009 +0100
+++ b/vregistry.py	Tue Feb 17 21:42:23 2009 +0100
@@ -243,7 +243,17 @@
 #     def clear(self, key):
 #         regname, oid = key.split('.')
 #         self[regname].pop(oid, None)
-        
+    def register_all(self, objects, modname, butclasses=()):
+        for obj in objects:
+            try:
+                if obj.__module__ != modname or obj in butclasses:
+                    continue
+                oid = obj.id
+            except AttributeError:
+                continue
+            if oid:
+                self.register(obj)
+                
     def register(self, obj, registryname=None, oid=None, clear=False):
         """base method to add an object in the registry"""
         registryname = registryname or obj.__registry__