doc update, move yes_registerer here tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 23:16:13 +0100
branchtls-sprint
changeset 718 f7011679437a
parent 717 54b873918b48
child 719 2a610efe21ce
doc update, move yes_registerer here
common/registerers.py
selectors.py
vregistry.py
--- a/common/registerers.py	Tue Feb 17 23:09:31 2009 +0100
+++ b/common/registerers.py	Tue Feb 17 23:16:13 2009 +0100
@@ -10,7 +10,7 @@
 """
 __docformat__ = "restructuredtext en"
 
-from cubicweb.vregistry import registerer
+from cubicweb.vregistry import registerer, yes_registerer
 from cubicweb.selectors import implements
 
 def _accepts_interfaces(obj):
@@ -20,11 +20,6 @@
     return sorted(getattr(obj, 'accepts_interfaces', ()))
 
 
-class yes_registerer(registerer):
-    """register without any other action"""
-    def do_it_yourself(self, registered):
-        return self.vobject
-
 class priority_registerer(registerer):
     """systematically kick previous registered class and register the
     wrapped class (based on the fact that directory containing vobjects
--- a/selectors.py	Tue Feb 17 23:09:31 2009 +0100
+++ b/selectors.py	Tue Feb 17 23:16:13 2009 +0100
@@ -1,7 +1,11 @@
 """This file contains some basic selectors required by application objects.
 
 A selector is responsible to score how well an object may be used with a
-given result set (publishing time selection)
+given context by returning a score.
+
+In CubicWeb Usually the context consists for a request object, a result set
+or None, a specific row/col in the result set, etc...
+
 
 If you have trouble with selectors, especially if the objet (typically
 a view or a component) you want to use is not selected and you want to
--- a/vregistry.py	Tue Feb 17 23:09:31 2009 +0100
+++ b/vregistry.py	Tue Feb 17 23:16:13 2009 +0100
@@ -74,21 +74,10 @@
     def skip(self):
         self.debug('no schema compat, skipping %s', self.vobject)
 
-
-def selector(cls, *args, **kwargs):
-    """selector is called to help choosing the correct object for a
-    particular request and result set by returning a score.
-
-    it must implement a .score_method taking a request, a result set and
-    optionaly row and col arguments which return an int telling how well
-    the wrapped class apply to the given request and result set. 0 score
-    means that it doesn't apply.
-    
-    rset may be None. If not, row and col arguments may be optionally
-    given if the registry is scoring a given row or a given cell of
-    the result set (both row and col are int if provided).
-    """    
-    raise NotImplementedError(cls)
+class yes_registerer(registerer):
+    """register without any other action"""
+    def do_it_yourself(self, registered):
+        return self.vobject
 
 
 class VObject(object):
@@ -575,6 +564,13 @@
 
     This class is only here to give access to binary operators, the
     selector logic itself should be implemented in the __call__ method
+
+
+    a selector is called to help choosing the correct object for a
+    particular context by returning a score (`int`) telling how well
+    the class given as first argument apply to the given context.
+
+    0 score means that the class doesn't apply.
     """
 
     @property
@@ -609,8 +605,8 @@
                                    "in its __call__ method" % self.__class__)
 
 class MultiSelector(Selector):
-    """base class for compound selector classes
-    """
+    """base class for compound selector classes"""
+    
     def __init__(self, *selectors):
         self.selectors = self.merge_selectors(selectors)