selectors.py
changeset 3399 2b84f4adb6f8
parent 3396 fb261afd49cd
child 3524 a3431f4e2f40
equal deleted inserted replaced
3398:d84b0176452c 3399:2b84f4adb6f8
   117     """Return XXX if the give object (maybe an instance or class) implements
   117     """Return XXX if the give object (maybe an instance or class) implements
   118     the interface.
   118     the interface.
   119     """
   119     """
   120     if getattr(iface, '__registry__', None) == 'etypes':
   120     if getattr(iface, '__registry__', None) == 'etypes':
   121         # adjust score if the interface is an entity class
   121         # adjust score if the interface is an entity class
   122         parents = etypesreg.parent_classes(cls_or_inst.id)
   122         parents = etypesreg.parent_classes(cls_or_inst.__regid__)
   123         if iface is cls:
   123         if iface is cls:
   124             return len(parents) + 4
   124             return len(parents) + 4
   125         if iface is parents[-1]: # Any
   125         if iface is parents[-1]: # Any
   126             return 1
   126             return 1
   127         for index, basecls in enumerate(reversed(parents[:-1])):
   127         for index, basecls in enumerate(reversed(parents[:-1])):
   425     """accept if:
   425     """accept if:
   426     * no context given
   426     * no context given
   427     * context (`basestring`) is matching the context property value for the
   427     * context (`basestring`) is matching the context property value for the
   428       given cls
   428       given cls
   429     """
   429     """
   430     propval = req.property_value('%s.%s.context' % (cls.__registry__, cls.id))
   430     propval = req.property_value('%s.%s.context' % (cls.__registry__,
       
   431                                                     cls.__regid__))
   431     if not propval:
   432     if not propval:
   432         propval = cls.context
   433         propval = cls.context
   433     if context is not None and propval and context != propval:
   434     if context is not None and propval and context != propval:
   434         return 0
   435         return 0
   435     return 1
   436     return 1
   540     """accept if the current view is in one of the expected vid given to the
   541     """accept if the current view is in one of the expected vid given to the
   541     initializer
   542     initializer
   542     """
   543     """
   543     @lltrace
   544     @lltrace
   544     def __call__(self, cls, req, rset=None, row=None, col=0, view=None, **kwargs):
   545     def __call__(self, cls, req, rset=None, row=None, col=0, view=None, **kwargs):
   545         if view is None or not view.id in self.expected:
   546         if view is None or not view.__regid__ in self.expected:
   546             return 0
   547             return 0
   547         return 1
   548         return 1
   548 
   549 
   549 
   550 
   550 class appobject_selectable(Selector):
   551 class appobject_selectable(Selector):