selectors.py
branchtls-sprint
changeset 769 2b49c9932d8c
parent 766 33ede72b22b8
child 770 193b7e981ea9
equal deleted inserted replaced
768:878e6139a46b 769:2b49c9932d8c
   447     """
   447     """
   448     
   448     
   449     @lltrace
   449     @lltrace
   450     def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs):
   450     def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs):
   451         user = req.user
   451         user = req.user
   452         print 'match_user_groups', user.login, user._groups, self.expected
       
   453         if user is None:
   452         if user is None:
   454             return int('guests' in self.expected)
   453             return int('guests' in self.expected)
   455         score = user.matching_groups(self.expected)
   454         score = user.matching_groups(self.expected)
   456         if not score and 'owners' in self.expected and rset:
   455         if not score and 'owners' in self.expected and rset:
   457             if row is not None:
   456             if row is not None:
   513                 score += 1
   512                 score += 1
   514                 if getattr(iface, '__registry__', None) == 'etypes':
   513                 if getattr(iface, '__registry__', None) == 'etypes':
   515                     score += 1
   514                     score += 1
   516                     # adjust score if the interface is an entity class
   515                     # adjust score if the interface is an entity class
   517                     if iface is eclass:
   516                     if iface is eclass:
   518                         score += len(eclass.e_schema.ancestors())
   517                         score += (len(eclass.e_schema.ancestors()) + 1)
   519 #                        print 'is majoration', len(eclass.e_schema.ancestors()) 
   518 #                        print 'is majoration', len(eclass.e_schema.ancestors()) 
   520                     else:
   519                     else:
   521                         parents = [e.type for e in eclass.e_schema.ancestors()]
   520                         parents = [e.type for e in eclass.e_schema.ancestors()]
   522                         for index, etype in enumerate(reversed(parents)):
   521                         for index, etype in enumerate(reversed(parents)):
   523                             basecls = eclass.vreg.etype_class(etype)
   522                             basecls = eclass.vreg.etype_class(etype)