cwvreg.py
branchstable
changeset 1923 3802c2e37e72
parent 1917 eaf6e0edc509
child 1977 606923dff11b
equal deleted inserted replaced
1922:1a0ddb675951 1923:3802c2e37e72
     9 
     9 
    10 from logilab.common.decorators import cached, clear_cache
    10 from logilab.common.decorators import cached, clear_cache
    11 
    11 
    12 from rql import RQLHelper
    12 from rql import RQLHelper
    13 
    13 
    14 from cubicweb import Binary, UnknownProperty, UnknownEid
    14 from cubicweb import ETYPE_NAME_MAP, Binary, UnknownProperty, UnknownEid
    15 from cubicweb.vregistry import VRegistry, ObjectNotFound, NoSelectableObject
    15 from cubicweb.vregistry import VRegistry, ObjectNotFound, NoSelectableObject
    16 from cubicweb.rtags import RTAGS
    16 from cubicweb.rtags import RTAGS
    17 
    17 
    18 
    18 
    19 def use_interfaces(obj):
    19 def use_interfaces(obj):
   168         eschema = self.schema.eschema(etype)
   168         eschema = self.schema.eschema(etype)
   169         baseschemas = [eschema] + eschema.ancestors()
   169         baseschemas = [eschema] + eschema.ancestors()
   170         # browse ancestors from most specific to most generic and
   170         # browse ancestors from most specific to most generic and
   171         # try to find an associated custom entity class
   171         # try to find an associated custom entity class
   172         for baseschema in baseschemas:
   172         for baseschema in baseschemas:
   173             btype = str(baseschema)
   173             try:
       
   174                 btype = ETYPE_NAME_MAP[baseschema]
       
   175             except KeyError:
       
   176                 btype = str(baseschema)
   174             try:
   177             try:
   175                 cls = self.select(self.registry_objects('etypes', btype), etype)
   178                 cls = self.select(self.registry_objects('etypes', btype), etype)
   176                 break
   179                 break
   177             except ObjectNotFound:
   180             except ObjectNotFound:
   178                 pass
   181                 pass
   385         """
   388         """
   386         for vobject in vobjects:
   389         for vobject in vobjects:
   387             vobject.vreg = self
   390             vobject.vreg = self
   388             vobject.schema = self.schema
   391             vobject.schema = self.schema
   389             vobject.config = self.config
   392             vobject.config = self.config
   390         return super(MulCnxCubicWebRegistry, self).select(vobjects, *args, **kwargs)
   393         selected = super(MulCnxCubicWebRegistry, self).select(vobjects, *args,
       
   394                                                               **kwargs)
       
   395         # redo the same thing on the instance so it won't use equivalent class
       
   396         # attributes (which may change)
       
   397         selected.vreg = self
       
   398         selected.schema = self.schema
       
   399         selected.config = self.config
       
   400         return selected
   391 
   401 
   392 from datetime import datetime, date, time, timedelta
   402 from datetime import datetime, date, time, timedelta
   393 
   403 
   394 YAMS_TO_PY = {
   404 YAMS_TO_PY = {
   395     'Boolean':  bool,
   405     'Boolean':  bool,