equal
deleted
inserted
replaced
100 else: |
100 else: |
101 self._needs_iface[obj] = ifaces |
101 self._needs_iface[obj] = ifaces |
102 |
102 |
103 def register(self, obj, **kwargs): |
103 def register(self, obj, **kwargs): |
104 if kwargs.get('registryname', obj.__registry__) == 'etypes': |
104 if kwargs.get('registryname', obj.__registry__) == 'etypes': |
|
105 if obj.id != 'Any' and not obj.id in self.schema: |
|
106 self.error('don\'t register %s, %s type not defined in the schema', |
|
107 obj, obj.id) |
|
108 return |
105 kwargs['clear'] = True |
109 kwargs['clear'] = True |
106 super(CubicWebRegistry, self).register(obj, **kwargs) |
110 super(CubicWebRegistry, self).register(obj, **kwargs) |
107 # XXX bw compat |
111 # XXX bw compat |
108 ifaces = use_interfaces(obj) |
112 ifaces = use_interfaces(obj) |
109 if ifaces: |
113 if ifaces: |
124 for cls in classes: |
128 for cls in classes: |
125 for iface in cls.__implements__: |
129 for iface in cls.__implements__: |
126 interfaces.update(expand_parent_classes(iface)) |
130 interfaces.update(expand_parent_classes(iface)) |
127 interfaces.update(expand_parent_classes(cls)) |
131 interfaces.update(expand_parent_classes(cls)) |
128 for obj, ifaces in self._needs_iface.items(): |
132 for obj, ifaces in self._needs_iface.items(): |
129 ifaces = frozenset(isinstance(iface, basestring) and self.etype_class(iface) or iface |
133 ifaces = frozenset(isinstance(iface, basestring) and iface in self.schema and self.etype_class(iface) or iface |
130 for iface in ifaces) |
134 for iface in ifaces) |
131 if not ifaces & interfaces: |
135 if not ifaces & interfaces: |
132 self.debug('kicking vobject %s (unsupported interface)', obj) |
136 self.debug('kicking vobject %s (unsupported interface)', obj) |
133 self.unregister(obj) |
137 self.unregister(obj) |
134 |
138 |