404 |
404 |
405 |
405 |
406 class ExpectedValueSelector(Selector): |
406 class ExpectedValueSelector(Selector): |
407 """Take a list of expected values as initializer argument and store them |
407 """Take a list of expected values as initializer argument and store them |
408 into the :attr:`expected` set attribute. You may also give a set as single |
408 into the :attr:`expected` set attribute. You may also give a set as single |
409 argument, which will be then be referenced as set of expected values, |
409 argument, which will then be referenced as set of expected values, |
410 allowing modifications to the given set to be considered. |
410 allowing modifications to the given set to be considered. |
411 |
411 |
412 You should implement one of :meth:`_values_set(cls, req, **kwargs)` or |
412 You should implement one of :meth:`_values_set(cls, req, **kwargs)` or |
413 :meth:`_get_value(cls, req, **kwargs)` method which should respectivly |
413 :meth:`_get_value(cls, req, **kwargs)` method which should respectively |
414 return the set of values or the unique possible value for the given context. |
414 return the set of values or the unique possible value for the given context. |
415 |
415 |
416 You may also specify a `mode` behaviour as argument, as explained below. |
416 You may also specify a `mode` behaviour as argument, as explained below. |
417 |
417 |
418 Returned score is: |
418 Returned score is: |
1503 |
1503 |
1504 def _values_set(self, cls, req, **kwargs): |
1504 def _values_set(self, cls, req, **kwargs): |
1505 return frozenset(req.form) |
1505 return frozenset(req.form) |
1506 |
1506 |
1507 |
1507 |
|
1508 class match_edited_type(ExpectedValueSelector): |
|
1509 """return non-zero if main edited entity type is the one specified as |
|
1510 initializer argument, or is among initializer arguments if `mode` == 'any'. |
|
1511 """ |
|
1512 |
|
1513 def _values_set(self, cls, req, **kwargs): |
|
1514 try: |
|
1515 return frozenset((req.form['__type:%s' % req.form['__maineid']],)) |
|
1516 except KeyError: |
|
1517 return frozenset() |
|
1518 |
|
1519 |
|
1520 class match_form_id(ExpectedValueSelector): |
|
1521 """return non-zero if request form identifier is the one specified as |
|
1522 initializer argument, or is among initializer arguments if `mode` == 'any'. |
|
1523 """ |
|
1524 |
|
1525 def _values_set(self, cls, req, **kwargs): |
|
1526 try: |
|
1527 return frozenset((req.form['__form_id'],)) |
|
1528 except KeyError: |
|
1529 return frozenset() |
|
1530 |
|
1531 |
1508 class specified_etype_implements(is_instance): |
1532 class specified_etype_implements(is_instance): |
1509 """Return non-zero score if the entity type specified by an 'etype' key |
1533 """Return non-zero score if the entity type specified by an 'etype' key |
1510 searched in (by priority) input context kwargs and request form parameters |
1534 searched in (by priority) input context kwargs and request form parameters |
1511 match a known entity type (case insensitivly), and it's associated entity |
1535 match a known entity type (case insensitivly), and it's associated entity |
1512 class is of one of the type(s) given to the initializer. If multiple |
1536 class is of one of the type(s) given to the initializer. If multiple |