cwvreg.py
branchstable
changeset 6037 1b4ea3ebdf80
parent 6014 a5e22657f6f4
child 6046 3fd4a34c4a09
equal deleted inserted replaced
6036:fe17d4bac785 6037:1b4ea3ebdf80
   203 
   203 
   204 from cubicweb import (ETYPE_NAME_MAP, Binary, UnknownProperty, UnknownEid,
   204 from cubicweb import (ETYPE_NAME_MAP, Binary, UnknownProperty, UnknownEid,
   205                       ObjectNotFound, NoSelectableObject, RegistryNotFound,
   205                       ObjectNotFound, NoSelectableObject, RegistryNotFound,
   206                       CW_EVENT_MANAGER)
   206                       CW_EVENT_MANAGER)
   207 from cubicweb.utils import dump_class
   207 from cubicweb.utils import dump_class
   208 from cubicweb.vregistry import VRegistry, Registry, class_regid
   208 from cubicweb.vregistry import VRegistry, Registry, class_regid, classid
   209 from cubicweb.rtags import RTAGS
   209 from cubicweb.rtags import RTAGS
   210 
   210 
   211 def clear_rtag_objects():
   211 def clear_rtag_objects():
   212     for rtag in RTAGS:
   212     for rtag in RTAGS:
   213         rtag.clear()
   213         rtag.clear()
   615                                    and self['etypes'].etype_class(iface)
   615                                    and self['etypes'].etype_class(iface)
   616                                    or iface
   616                                    or iface
   617                                    for iface in ifaces)
   617                                    for iface in ifaces)
   618                 if not ('Any' in ifaces or ifaces & implemented_interfaces):
   618                 if not ('Any' in ifaces or ifaces & implemented_interfaces):
   619                     self.debug('unregister %s (no implemented '
   619                     self.debug('unregister %s (no implemented '
   620                                'interface among %s)', obj, ifaces)
   620                                'interface among %s)', classid(obj), ifaces)
   621                     self.unregister(obj)
   621                     self.unregister(obj)
   622             # since 3.9: remove appobjects which depending on other, unexistant
   622             # since 3.9: remove appobjects which depending on other, unexistant
   623             # appobjects
   623             # appobjects
   624             for obj, (regname, regids) in self._needs_appobject.items():
   624             for obj, (regname, regids) in self._needs_appobject.items():
   625                 try:
   625                 try:
   626                     registry = self[regname]
   626                     registry = self[regname]
   627                 except RegistryNotFound:
   627                 except RegistryNotFound:
   628                     self.debug('unregister %s (no registry %s)', obj, regname)
   628                     self.debug('unregister %s (no registry %s)', classid(obj),
       
   629                                regname)
   629                     self.unregister(obj)
   630                     self.unregister(obj)
   630                     continue
   631                     continue
   631                 for regid in regids:
   632                 for regid in regids:
   632                     if registry.get(regid):
   633                     if registry.get(regid):
   633                         break
   634                         break
   634                 else:
   635                 else:
   635                     self.debug('unregister %s (no %s object in registry %s)',
   636                     self.debug('unregister %s (no %s object in registry %s)',
   636                                obj, ' or '.join(regids), regname)
   637                                classid(obj), ' or '.join(regids), regname)
   637                     self.unregister(obj)
   638                     self.unregister(obj)
   638         super(CubicWebVRegistry, self).initialization_completed()
   639         super(CubicWebVRegistry, self).initialization_completed()
   639         for rtag in RTAGS:
   640         for rtag in RTAGS:
   640             # don't check rtags if we don't want to cleanup_interface_sobjects
   641             # don't check rtags if we don't want to cleanup_interface_sobjects
   641             rtag.init(self.schema, check=self.config.cleanup_interface_sobjects)
   642             rtag.init(self.schema, check=self.config.cleanup_interface_sobjects)