selectors.py
changeset 3369 7b88d12b4ee2
parent 3293 69c0ba095536
parent 3350 fa77640a9155
child 3378 2f25f701301d
child 3393 58a62864bae4
equal deleted inserted replaced
3300:c7c4775a5619 3369:7b88d12b4ee2
   526 
   526 
   527 class match_transition(match_search_state):
   527 class match_transition(match_search_state):
   528     @lltrace
   528     @lltrace
   529     def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs):
   529     def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs):
   530         try:
   530         try:
   531             trname = req.execute('Any XN WHERE X is Transition, X eid %(x)s, X name XN',
   531             # XXX check this is a transition that apply to the object?
   532                                  {'x': typed_eid(req.form['treid'])})[0][0]
   532             if not kwargs['transition'].name in self.expected:
   533         except (KeyError, IndexError):
   533                 return 0
   534             return 0
   534         except KeyError:
   535         # XXX check this is a transition that apply to the object?
       
   536         if not trname in self.expected:
       
   537             return 0
   535             return 0
   538         return 1
   536         return 1
   539 
   537 
   540 
   538 
   541 class match_view(match_search_state):
   539 class match_view(match_search_state):
   610         except KeyError:
   608         except KeyError:
   611             try:
   609             try:
   612                 etype = req.form['etype']
   610                 etype = req.form['etype']
   613             except KeyError:
   611             except KeyError:
   614                 return 0
   612                 return 0
   615         else:
   613             else:
   616             # only check this is a known type if etype comes from req.form,
   614                 # only check this is a known type if etype comes from req.form,
   617             # else we want the error to propagate
   615                 # else we want the error to propagate
   618             try:
   616                 try:
   619                 etype = req.vreg.case_insensitive_etypes[etype.lower()]
   617                     etype = cls.vreg.case_insensitive_etypes[etype.lower()]
   620                 req.form['etype'] = etype
   618                     req.form['etype'] = etype
   621             except KeyError:
   619                 except KeyError:
   622                 return 0
   620                     return 0
   623         return self.score_class(req.vreg['etypes'].etype_class(etype), req)
   621         return self.score_class(cls.vreg['etypes'].etype_class(etype), req)
   624 
   622 
   625 
   623 
   626 class entity_implements(ImplementsMixIn, EntitySelector):
   624 class entity_implements(ImplementsMixIn, EntitySelector):
   627     """accept if entity instances found in the result set implements at least one
   625     """accept if entity instances found in the result set implements at least one
   628     of the interfaces given as argument. Returned score is the number of
   626     of the interfaces given as argument. Returned score is the number of
   668     def __call__(self, cls, req, *args, **kwargs):
   666     def __call__(self, cls, req, *args, **kwargs):
   669         rschema = req.vreg.schema.rschema(self.rtype)
   667         rschema = req.vreg.schema.rschema(self.rtype)
   670         if not (rschema.has_perm(req, self.action)
   668         if not (rschema.has_perm(req, self.action)
   671                 or rschema.has_local_role(self.action)):
   669                 or rschema.has_local_role(self.action)):
   672             return 0
   670             return 0
       
   671         if self.action != 'read':
       
   672             if not (rschema.has_perm(req, 'read')
       
   673                     or rschema.has_local_role('read')):
       
   674                 return 0
   673         score = super(relation_possible, self).__call__(cls, req, *args, **kwargs)
   675         score = super(relation_possible, self).__call__(cls, req, *args, **kwargs)
   674         return score
   676         return score
   675 
   677 
   676     def score_class(self, eclass, req):
   678     def score_class(self, eclass, req):
   677         eschema = eclass.e_schema
   679         eschema = eclass.e_schema