drop more registerers tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 17:13:55 +0100
branchtls-sprint
changeset 670 6c332f5c969c
parent 669 5d2132832f03
child 671 4ae56cfd530d
child 678 4a29050fe143
drop more registerers
common/registerers.py
web/action.py
web/box.py
web/component.py
--- a/common/registerers.py	Tue Feb 17 16:57:19 2009 +0100
+++ b/common/registerers.py	Tue Feb 17 17:13:55 2009 +0100
@@ -125,54 +125,6 @@
     
     def equivalent(self, other):
         return other.id == self.vobject.id
-
-
-class etype_rtype_registerer(registerer):
-    """registerer handling optional .etype and .rtype attributes.:
-    
-    * if .etype is set and is not an entity type defined in the
-      application schema, skip the wrapped class
-    * if .rtype or .relname is set and is not a relation type defined in
-      the application schema, skip the wrapped class
-    * register
-    """
-    def do_it_yourself(self, registered):
-        cls = self.vobject
-        if hasattr(cls, 'etype'):
-            if not self.schema.has_entity(cls.etype):
-                return
-        rtype = getattr(cls, 'rtype', None)
-        if rtype and not self.schema.has_relation(rtype):
-            return
-        return cls
-
-class etype_rtype_priority_registerer(etype_rtype_registerer):
-    """add priority behaviour to the etype_rtype_registerer
-    """
-    def do_it_yourself(self, registered):
-        cls = super(etype_rtype_priority_registerer, self).do_it_yourself(registered)
-        if cls:
-            registerer = priority_registerer(self.registry, cls)
-            cls = registerer.do_it_yourself(registered)
-        return cls
-
-class action_registerer(etype_rtype_registerer):
-    """'all in one' actions registerer, handling optional .accepts,
-    .etype and .rtype attributes:
-    
-    * if .etype is set and is not an entity type defined in the
-      application schema, skip the wrapped class
-    * if .rtype or .relname is set and is not a relation type defined in
-      the application schema, skip the wrapped class
-    * if .accepts is set, delegate to the accepts_registerer
-    * register
-    """
-    def do_it_yourself(self, registered):
-        cls = super(action_registerer, self).do_it_yourself(registered)
-        if hasattr(cls, 'accepts'):
-            registerer = accepts_registerer(self.registry, cls)
-            cls = registerer.do_it_yourself(registered)
-        return cls
     
 
 __all__ = [cls.__name__ for cls in globals().values()
--- a/web/action.py	Tue Feb 17 16:57:19 2009 +0100
+++ b/web/action.py	Tue Feb 17 17:13:55 2009 +0100
@@ -11,7 +11,7 @@
                                 one_line_rset, may_add_relation, yes,
                                 accepts_compat, condition_compat, deprecate)
 from cubicweb.common.appobject import AppRsetObject
-from cubicweb.common.registerers import action_registerer
+from cubicweb.common.registerers import accepts_registerer
 
 _ = unicode
 
@@ -21,7 +21,7 @@
     request search state. 
     """
     __registry__ = 'actions'
-    __registerer__ = action_registerer
+    __registerer__ = accepts_registerer
     __selectors__ = (yes,) 
     
     property_defs = {
--- a/web/box.py	Tue Feb 17 16:57:19 2009 +0100
+++ b/web/box.py	Tue Feb 17 17:13:55 2009 +0100
@@ -13,9 +13,7 @@
 from cubicweb.selectors import (one_line_rset,  primary_view,
                                 match_context_prop, has_related_entities,
                                 accepts_compat, condition_compat)
-from cubicweb.common.registerers import (
-    accepts_registerer, extresources_registerer,
-    etype_rtype_priority_registerer)
+from cubicweb.common.registerers import accepts_registerer, priority_registerer
 #etype_rtype_selector, has_relation,
 from cubicweb.common.view import Template, ReloadableMixIn
 
@@ -104,7 +102,7 @@
     according to application schema and display according to connected
     user's rights) and rql attributes
     """
-    __registerer__ = etype_rtype_priority_registerer
+    __registerer__ = priority_registerer
 #XXX    __selectors__ = BoxTemplate.__selectors__ + (etype_rtype_selector,)
 
     rql  = None
--- a/web/component.py	Tue Feb 17 16:57:19 2009 +0100
+++ b/web/component.py	Tue Feb 17 17:13:55 2009 +0100
@@ -14,7 +14,7 @@
 from cubicweb.common.appobject import Component
 from cubicweb.common.utils import merge_dicts
 from cubicweb.common.view import View
-from cubicweb.common.registerers import action_registerer
+from cubicweb.common.registerers import accepts_registerer
 from cubicweb.common.uilib import html_escape
 
 _ = unicode
@@ -31,7 +31,7 @@
     """
     
     __registry__ = 'contentnavigation'
-    __registerer__ = action_registerer    
+    __registerer__ = accepts_registerer    
     __selectors__ = (one_line_rset, primary_view, match_context_prop,)
     registered = accepts_compat(has_relation_compat(condition_compat(View.registered.im_func)))