predicates.py
branchstable
changeset 8481 ff3b163f52e9
parent 8397 42ec34b3ced9
child 8528 f32c50c6b7e0
equal deleted inserted replaced
8480:086cff6a306a 8481:ff3b163f52e9
   350        while the former works on each *entity* (eg each row of the result set),
   350        while the former works on each *entity* (eg each row of the result set),
   351        which may be much more costly.
   351        which may be much more costly.
   352     """
   352     """
   353 
   353 
   354     def __call__(self, cls, req, rset=None, row=None, col=0, accept_none=None,
   354     def __call__(self, cls, req, rset=None, row=None, col=0, accept_none=None,
   355                  **kwargs):
   355                  entity=None, **kwargs):
   356         if not rset and not kwargs.get('entity'):
   356         if not rset and entity is None:
   357             return 0
   357             return 0
   358         score = 0
   358         score = 0
   359         if kwargs.get('entity'):
   359         if entity is not None:
   360             score = self.score_entity(kwargs['entity'])
   360             score = self.score_entity(entity)
   361         elif row is None:
   361         elif row is None:
   362             col = col or 0
   362             col = col or 0
   363             if accept_none is None:
   363             if accept_none is None:
   364                 accept_none = self.accept_none
   364                 accept_none = self.accept_none
   365             for row, rowvalue in enumerate(rset.rows):
   365             for row, rowvalue in enumerate(rset.rows):
  1074     def __init__(self, action):
  1074     def __init__(self, action):
  1075         self.action = action
  1075         self.action = action
  1076 
  1076 
  1077     # don't use EntityPredicate.__call__ but this optimized implementation to
  1077     # don't use EntityPredicate.__call__ but this optimized implementation to
  1078     # avoid considering each entity when it's not necessary
  1078     # avoid considering each entity when it's not necessary
  1079     def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs):
  1079     def __call__(self, cls, req, rset=None, row=None, col=0, entity=None, **kwargs):
  1080         if kwargs.get('entity'):
  1080         if entity is not None:
  1081             return self.score_entity(kwargs['entity'])
  1081             return self.score_entity(entity)
  1082         if rset is None:
  1082         if rset is None:
  1083             return 0
  1083             return 0
  1084         if row is None:
  1084         if row is None:
  1085             score = 0
  1085             score = 0
  1086             need_local_check = []
  1086             need_local_check = []