kill id_registerer tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 23:09:31 +0100
branchtls-sprint
changeset 717 54b873918b48
parent 715 83228d379cbe
child 718 f7011679437a
kill id_registerer
common/registerers.py
cwvreg.py
entity.py
--- a/common/registerers.py	Tue Feb 17 23:08:21 2009 +0100
+++ b/common/registerers.py	Tue Feb 17 23:09:31 2009 +0100
@@ -97,28 +97,6 @@
             return False
 
 
-class id_registerer(priority_registerer):
-    """register according to the "id" attribute of the wrapped class,
-    refering to an entity type.
-    
-    * if the type is not Any and is not defined the application'schema,
-      skip the wrapped class
-    * if an object previously registered has the same .id attribute,
-      kick it out
-    * register
-    """
-    def do_it_yourself(self, registered):
-        etype = self.vobject.id
-        if etype != 'Any' and not self.schema.has_entity(etype):
-            self.skip()
-            return
-        self.remove_equivalents(registered)
-        return self.vobject
-    
-    def equivalent(self, other):
-        return other.id == self.vobject.id
-    
-
 __all__ = [cls.__name__ for cls in globals().values()
            if isinstance(cls, type) and issubclass(cls, registerer)
            and not cls is registerer]
--- a/cwvreg.py	Tue Feb 17 23:08:21 2009 +0100
+++ b/cwvreg.py	Tue Feb 17 23:09:31 2009 +0100
@@ -87,6 +87,8 @@
         self.register(obj, **kwargs)
 
     def register(self, obj, **kwargs):
+        if kwargs.get('registryname', obj.__registry__) == 'etypes':
+            kwargs['clear'] = True
         super(CubicWebRegistry, self).register(obj, **kwargs)
         # XXX bw compat
         ifaces = getattr(obj, 'accepts_interfaces', None)
--- a/entity.py	Tue Feb 17 23:08:21 2009 +0100
+++ b/entity.py	Tue Feb 17 23:09:31 2009 +0100
@@ -18,7 +18,6 @@
 from cubicweb.selectors import yes
 from cubicweb.appobject import AppRsetObject
 from cubicweb.schema import RQLVocabularyConstraint, RQLConstraint, bw_normalize_etype
-from cubicweb.common.registerers import id_registerer
 
 try:
     from cubicweb.common.uilib import printable_value, soup2xhtml
@@ -222,8 +221,7 @@
     """
     __metaclass__ = metaentity
     __registry__ = 'etypes'
-    __registerer__ = id_registerer
-    __selectors__ = (yes,)
+    __select__ = yes()
     widgets = {}
     id = None
     e_schema = None