doc/book/en/02-01-concepts.en.txt
changeset 120 ec4055760654
parent 119 7a56ca431d65
child 123 c5dd68070dea
equal deleted inserted replaced
119:7a56ca431d65 120:ec4055760654
   196 * a selector return a score >= 0
   196 * a selector return a score >= 0
   197 * a score of 0 means the objects can't be applied to the input context
   197 * a score of 0 means the objects can't be applied to the input context
   198 * the object with the greatest score is selected. If multiple objects have an
   198 * the object with the greatest score is selected. If multiple objects have an
   199   identical score, one of them is selected randomly (this is usually a bug)
   199   identical score, one of them is selected randomly (this is usually a bug)
   200 
   200 
   201 The object's selector is the `__selector__` class method on the object's class.
   201 The object's selector is the `__select__` class method on the object's class.
   202 
   202 
   203 The score is used to choose the most pertinent objects where there are more than
   203 The score is used to choose the most pertinent objects where there are more than
   204 one selectable object. For instance, if you're selecting the primary
   204 one selectable object. For instance, if you're selecting the primary
   205 (eg `id = 'primary'`) view (eg `__registry__ = 'view'`) for a result set containing
   205 (eg `id = 'primary'`) view (eg `__registry__ = 'view'`) for a result set containing
   206 a `Card` entity, 2 objects will probably be selectable:
   206 a `Card` entity, 2 objects will probably be selectable:
   219 
   219 
   220   __selectors__ = (sel1, sel2)
   220   __selectors__ = (sel1, sel2)
   221 
   221 
   222 which is equivalent to ::
   222 which is equivalent to ::
   223 
   223 
   224   __selector__ = chainall(sel1, sel2)
   224   __select__ = chainall(sel1, sel2)
   225 
   225 
   226 The former is prefered since it's shorter and it's ease overriding in
   226 The former is prefered since it's shorter and it's ease overriding in
   227 subclasses (you have access to sub-selectors instead of the wrapping function).
   227 subclasses (you have access to sub-selectors instead of the wrapping function).
   228 
   228 
   229 :chainall(selectors...): if one selector return 0, return 0, else return the sum of scores
   229 :chainall(selectors...): if one selector return 0, return 0, else return the sum of scores