# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1236710176 -3600 # Node ID 1f3fae8d82b233d6a0cf62b38fb4d91666c76df0 # Parent 593df4919845a215dd291439e69d99a4178d1974 don't fail if vobjects reference an unexistant class diff -r 593df4919845 -r 1f3fae8d82b2 cwvreg.py --- a/cwvreg.py Tue Mar 10 19:35:38 2009 +0100 +++ b/cwvreg.py Tue Mar 10 19:36:16 2009 +0100 @@ -102,6 +102,10 @@ def register(self, obj, **kwargs): if kwargs.get('registryname', obj.__registry__) == 'etypes': + if obj.id != 'Any' and not obj.id in self.schema: + self.error('don\'t register %s, %s type not defined in the schema', + obj, obj.id) + return kwargs['clear'] = True super(CubicWebRegistry, self).register(obj, **kwargs) # XXX bw compat @@ -126,7 +130,7 @@ interfaces.update(expand_parent_classes(iface)) interfaces.update(expand_parent_classes(cls)) for obj, ifaces in self._needs_iface.items(): - ifaces = frozenset(isinstance(iface, basestring) and self.etype_class(iface) or iface + ifaces = frozenset(isinstance(iface, basestring) and iface in self.schema and self.etype_class(iface) or iface for iface in ifaces) if not ifaces & interfaces: self.debug('kicking vobject %s (unsupported interface)', obj) diff -r 593df4919845 -r 1f3fae8d82b2 selectors.py --- a/selectors.py Tue Mar 10 19:35:38 2009 +0100 +++ b/selectors.py Tue Mar 10 19:36:16 2009 +0100 @@ -522,7 +522,10 @@ for iface in self.expected_ifaces: if isinstance(iface, basestring): # entity type - iface = eclass.vreg.etype_class(iface) + try: + iface = eclass.vreg.etype_class(iface) + except KeyError: + continue # entity type not in the schema if implements_iface(eclass, iface): if getattr(iface, '__registry__', None) == 'etypes': # adjust score if the interface is an entity class