Commit 4c33b368 authored by's avatar
Browse files

test and fix interface based objects cleaning

branch : tls-sprint
parent 29ba95ea7e7d
......@@ -105,7 +105,7 @@ class CubicWebRegistry(VRegistry):
kwargs['clear'] = True
super(CubicWebRegistry, self).register(obj, **kwargs)
# XXX bw compat
ifaces = getattr(obj, 'accepts_interfaces', None)
ifaces = use_interfaces(obj)
if ifaces:
self._needs_iface[obj] = frozenset(ifaces)
......@@ -122,12 +122,15 @@ class CubicWebRegistry(VRegistry):
interfaces = set()
for classes in self.get('etypes', {}).values():
for cls in classes:
for iface in cls.__implements__:
for obj, ifaces in self._needs_iface.items():
if not ifaces & interfaces:
self.debug('kicking vobject %s (unsupported interface)', obj)
def eid_rset(self, cursor, eid, etype=None):
"""return a result set for the given eid without doing actual query
(we have the eid, we can suppose it exists and user has access to the
......@@ -5,7 +5,9 @@ from os.path import join
from cubicweb import CW_SOFTWARE_ROOT as BASE
from cubicweb.vregistry import VObject
from cubicweb.cwvreg import CubicWebRegistry, UnknownProperty
from cubicweb.cwconfig import CubicWebConfiguration
from cubicweb.devtools import TestServerConfiguration
from cubicweb.entities.lib import Card
from cubicweb.interfaces import IMileStone
class YesSchema:
def __contains__(self, something):
......@@ -14,9 +16,10 @@ class YesSchema:
class VRegistryTC(TestCase):
def setUp(self):
config = CubicWebConfiguration('data')
config = TestServerConfiguration('data')
self.vreg = CubicWebRegistry(config)
self.vreg.schema = YesSchema()
self.vreg.schema = config.load_schema()
def test_load(self):
self.vreg.load_file(join(BASE, 'web', 'views'), '')
......@@ -45,6 +48,19 @@ class VRegistryTC(TestCase):
self.failIf('system.version.cubicweb' in self.vreg['propertydefs'])
self.assertRaises(UnknownProperty, self.vreg.property_info, 'a.non.existent.key')
def test_load_subinterface_based_vobjects(self):
self.vreg.register_objects([join(BASE, 'web', 'views', '')])
# check progressbar was kicked
class MyCard(Card):
__implements__ = (IMileStone,)
self.vreg.register_objects([join(BASE, 'web', 'views', '')])
# check progressbar isn't kicked
self.assertEquals(len(self.vreg['views']['progressbar']), 1)
if __name__ == '__main__':
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment