cwvreg.py
changeset 2829 054a8805da52
parent 2824 3455f72010fe
child 2894 4b720d82a1e4
--- a/cwvreg.py	Thu Aug 13 13:06:10 2009 +0200
+++ b/cwvreg.py	Thu Aug 13 13:07:21 2009 +0200
@@ -18,7 +18,7 @@
                       ObjectNotFound, NoSelectableObject, RegistryNotFound,
                       RegistryOutOfDate, CW_EVENT_MANAGER)
 from cubicweb.utils import dump_class
-from cubicweb.vregistry import VRegistry, Registry
+from cubicweb.vregistry import VRegistry, Registry, class_regid
 from cubicweb.rtags import RTAGS
 
 
@@ -96,10 +96,10 @@
         clear_cache(self, 'etype_class')
 
     def register(self, obj, **kwargs):
-        oid = kwargs.get('oid') or obj.id
+        oid = kwargs.get('oid') or class_regid(obj)
         if oid != 'Any' and not oid in self.schema:
             self.error('don\'t register %s, %s type not defined in the '
-                       'schema', obj, obj.id)
+                       'schema', obj, oid)
             return
         kwargs['clear'] = True
         super(ETypeRegistry, self).register(obj, **kwargs)
@@ -145,11 +145,11 @@
             objects = self['Any']
             assert len(objects) == 1, objects
             cls = objects[0]
-        if cls.id == etype:
+        if cls.__id__ == etype:
             cls.__initialize__(self.schema)
             return cls
         cls = dump_class(cls, etype)
-        cls.id = etype
+        cls.__id__ = etype
         cls.__initialize__(self.schema)
         return cls