Commit 65ceacf7 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

initialize property once initialization has been fully completed, close #666573

--HG--
branch : stable
parent d87989d91635
......@@ -295,7 +295,6 @@ class AppObject(object):
cls.vreg = registry.vreg
cls.schema = registry.schema
cls.config = registry.config
cls.register_properties()
return cls
@classmethod
......
......@@ -379,6 +379,9 @@ class CubicWebVRegistry(VRegistry):
for regname, reg in self.items():
self.debug('available in registry %s: %s', regname, sorted(reg))
reg.initialization_completed()
for appobjects in reg.itervalues():
for appobjectcls in appobjects:
appobjectcls.register_properties()
# we may want to keep interface dependent objects (e.g.for i18n
# catalog generation)
if self.config.cleanup_interface_sobjects:
......
......@@ -13,6 +13,7 @@ from cubicweb import CW_SOFTWARE_ROOT as BASE
from cubicweb.appobject import AppObject
from cubicweb.cwvreg import CubicWebVRegistry, UnknownProperty
from cubicweb.devtools import TestServerConfiguration
from cubicweb.devtools.apptest import EnvBasedTC
from cubicweb.interfaces import IMileStone
from cubes.card.entities import Card
......@@ -31,15 +32,6 @@ class VRegistryTC(TestCase):
config.bootstrap_cubes()
self.vreg.schema = config.load_schema()
def test_load_interface_based_vojects(self):
self.vreg.init_registration([WEBVIEWSDIR])
self.vreg.load_file(join(BASE, 'entities', '__init__.py'), 'cubicweb.entities.__init__')
self.vreg.load_file(join(WEBVIEWSDIR, 'idownloadable.py'), 'cubicweb.web.views.idownloadable')
self.vreg.load_file(join(WEBVIEWSDIR, 'primary.py'), 'cubicweb.web.views.primary')
self.assertEquals(len(self.vreg['views']['primary']), 2)
self.vreg.initialization_completed()
self.assertEquals(len(self.vreg['views']['primary']), 1)
def test___selectors__compat(self):
myselector1 = lambda *args: 1
myselector2 = lambda *args: 1
......@@ -48,10 +40,14 @@ class VRegistryTC(TestCase):
AnAppObject.build___select__()
self.assertEquals(AnAppObject.__select__(AnAppObject), 2)
def test_properties(self):
self.failIf('system.version.cubicweb' in self.vreg['propertydefs'])
self.failUnless(self.vreg.property_info('system.version.cubicweb'))
self.assertRaises(UnknownProperty, self.vreg.property_info, 'a.non.existent.key')
def test_load_interface_based_vojects(self):
self.vreg.init_registration([WEBVIEWSDIR])
self.vreg.load_file(join(BASE, 'entities', '__init__.py'), 'cubicweb.entities.__init__')
self.vreg.load_file(join(WEBVIEWSDIR, 'idownloadable.py'), 'cubicweb.web.views.idownloadable')
self.vreg.load_file(join(WEBVIEWSDIR, 'primary.py'), 'cubicweb.web.views.primary')
self.assertEquals(len(self.vreg['views']['primary']), 2)
self.vreg.initialization_completed()
self.assertEquals(len(self.vreg['views']['primary']), 1)
def test_load_subinterface_based_appobjects(self):
self.vreg.reset()
......@@ -68,6 +64,17 @@ class VRegistryTC(TestCase):
# check progressbar isn't kicked
self.assertEquals(len(self.vreg['views']['progressbar']), 1)
def test_properties(self):
self.failIf('system.version.cubicweb' in self.vreg['propertydefs'])
self.failUnless(self.vreg.property_info('system.version.cubicweb'))
self.assertRaises(UnknownProperty, self.vreg.property_info, 'a.non.existent.key')
class CWVregTC(EnvBasedTC):
def test_property_default_overriding(self):
# see data/views.py
from cubicweb.web.views.xmlrss import RSSIconBox
self.assertEquals(self.vreg.property_info(RSSIconBox.propkey('visible'))['default'], True)
if __name__ == '__main__':
unittest_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