Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
5f99eb0b99f7
Commit
65ceacf7
authored
Feb 06, 2010
by
Sylvain Thénault
Browse files
initialize property once initialization has been fully completed, close #666573
--HG-- branch : stable
parent
d87989d91635
Changes
3
Hide whitespace changes
Inline
Side-by-side
appobject.py
View file @
5f99eb0b
...
@@ -295,7 +295,6 @@ class AppObject(object):
...
@@ -295,7 +295,6 @@ class AppObject(object):
cls
.
vreg
=
registry
.
vreg
cls
.
vreg
=
registry
.
vreg
cls
.
schema
=
registry
.
schema
cls
.
schema
=
registry
.
schema
cls
.
config
=
registry
.
config
cls
.
config
=
registry
.
config
cls
.
register_properties
()
return
cls
return
cls
@
classmethod
@
classmethod
...
...
cwvreg.py
View file @
5f99eb0b
...
@@ -379,6 +379,9 @@ class CubicWebVRegistry(VRegistry):
...
@@ -379,6 +379,9 @@ class CubicWebVRegistry(VRegistry):
for
regname
,
reg
in
self
.
items
():
for
regname
,
reg
in
self
.
items
():
self
.
debug
(
'available in registry %s: %s'
,
regname
,
sorted
(
reg
))
self
.
debug
(
'available in registry %s: %s'
,
regname
,
sorted
(
reg
))
reg
.
initialization_completed
()
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
# we may want to keep interface dependent objects (e.g.for i18n
# catalog generation)
# catalog generation)
if
self
.
config
.
cleanup_interface_sobjects
:
if
self
.
config
.
cleanup_interface_sobjects
:
...
...
test/unittest_vregistry.py
View file @
5f99eb0b
...
@@ -13,6 +13,7 @@ from cubicweb import CW_SOFTWARE_ROOT as BASE
...
@@ -13,6 +13,7 @@ from cubicweb import CW_SOFTWARE_ROOT as BASE
from
cubicweb.appobject
import
AppObject
from
cubicweb.appobject
import
AppObject
from
cubicweb.cwvreg
import
CubicWebVRegistry
,
UnknownProperty
from
cubicweb.cwvreg
import
CubicWebVRegistry
,
UnknownProperty
from
cubicweb.devtools
import
TestServerConfiguration
from
cubicweb.devtools
import
TestServerConfiguration
from
cubicweb.devtools.apptest
import
EnvBasedTC
from
cubicweb.interfaces
import
IMileStone
from
cubicweb.interfaces
import
IMileStone
from
cubes.card.entities
import
Card
from
cubes.card.entities
import
Card
...
@@ -31,15 +32,6 @@ class VRegistryTC(TestCase):
...
@@ -31,15 +32,6 @@ class VRegistryTC(TestCase):
config
.
bootstrap_cubes
()
config
.
bootstrap_cubes
()
self
.
vreg
.
schema
=
config
.
load_schema
()
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
):
def
test___selectors__compat
(
self
):
myselector1
=
lambda
*
args
:
1
myselector1
=
lambda
*
args
:
1
myselector2
=
lambda
*
args
:
1
myselector2
=
lambda
*
args
:
1
...
@@ -48,10 +40,14 @@ class VRegistryTC(TestCase):
...
@@ -48,10 +40,14 @@ class VRegistryTC(TestCase):
AnAppObject
.
build___select__
()
AnAppObject
.
build___select__
()
self
.
assertEquals
(
AnAppObject
.
__select__
(
AnAppObject
),
2
)
self
.
assertEquals
(
AnAppObject
.
__select__
(
AnAppObject
),
2
)
def
test_properties
(
self
):
def
test_load_interface_based_vojects
(
self
):
self
.
failIf
(
'system.version.cubicweb'
in
self
.
vreg
[
'propertydefs'
])
self
.
vreg
.
init_registration
([
WEBVIEWSDIR
])
self
.
failUnless
(
self
.
vreg
.
property_info
(
'system.version.cubicweb'
))
self
.
vreg
.
load_file
(
join
(
BASE
,
'entities'
,
'__init__.py'
),
'cubicweb.entities.__init__'
)
self
.
assertRaises
(
UnknownProperty
,
self
.
vreg
.
property_info
,
'a.non.existent.key'
)
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
):
def
test_load_subinterface_based_appobjects
(
self
):
self
.
vreg
.
reset
()
self
.
vreg
.
reset
()
...
@@ -68,6 +64,17 @@ class VRegistryTC(TestCase):
...
@@ -68,6 +64,17 @@ class VRegistryTC(TestCase):
# check progressbar isn't kicked
# check progressbar isn't kicked
self
.
assertEquals
(
len
(
self
.
vreg
[
'views'
][
'progressbar'
]),
1
)
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__'
:
if
__name__
==
'__main__'
:
unittest_main
()
unittest_main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment