selectors.py
branchstable
changeset 4719 aaed3f813ef8
parent 4664 bd5ecd5b9494
child 4833 41a78fb4107c
equal deleted inserted replaced
4718:3dc3ad02d091 4719:aaed3f813ef8
    41 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
    41 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
    42 """
    42 """
    43 __docformat__ = "restructuredtext en"
    43 __docformat__ = "restructuredtext en"
    44 
    44 
    45 import logging
    45 import logging
    46 from warnings import warn, filterwarnings
    46 from warnings import warn
    47 
    47 
    48 from logilab.common.deprecation import class_renamed
    48 from logilab.common.deprecation import class_renamed
    49 from logilab.common.compat import all, any
    49 from logilab.common.compat import all, any
    50 from logilab.common.interface import implements as implements_iface
    50 from logilab.common.interface import implements as implements_iface
    51 
    51 
    52 from yams import BASE_TYPES
    52 from yams import BASE_TYPES
    53 
    53 
    54 from cubicweb import (Unauthorized, NoSelectableObject, NotAnEntity,
    54 from cubicweb import Unauthorized, NoSelectableObject, NotAnEntity, role
    55                       role, typed_eid)
       
    56 # even if not used, let yes here so it's importable through this module
    55 # even if not used, let yes here so it's importable through this module
    57 from cubicweb.appobject import Selector, objectify_selector, yes
    56 from cubicweb.appobject import Selector, objectify_selector, yes
    58 from cubicweb.vregistry import class_regid
    57 from cubicweb.vregistry import class_regid
    59 from cubicweb.cwconfig import CubicWebConfiguration
    58 from cubicweb.cwconfig import CubicWebConfiguration
    60 from cubicweb.schema import split_expression
    59 from cubicweb.schema import split_expression
   161                            ','.join(str(s) for s in self.expected_ifaces))
   160                            ','.join(str(s) for s in self.expected_ifaces))
   162 
   161 
   163     def score_interfaces(self, req, cls_or_inst, cls):
   162     def score_interfaces(self, req, cls_or_inst, cls):
   164         score = 0
   163         score = 0
   165         etypesreg = req.vreg['etypes']
   164         etypesreg = req.vreg['etypes']
   166         eschema = cls_or_inst.e_schema
       
   167         for iface in self.expected_ifaces:
   165         for iface in self.expected_ifaces:
   168             if isinstance(iface, basestring):
   166             if isinstance(iface, basestring):
   169                 # entity type
   167                 # entity type
   170                 try:
   168                 try:
   171                     iface = etypesreg.etype_class(iface)
   169                     iface = etypesreg.etype_class(iface)