Commit 5811b33f authored by sylvain.thenault@logilab.fr's avatar sylvain.thenault@logilab.fr
Browse files

fix some rtags pb on i18n catalog generation

--HG--
branch : tls-sprint
parent b59b7c422a8a
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
""" """
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
_ = unicode
from logilab.common.decorators import cached, clear_cache from logilab.common.decorators import cached, clear_cache
...@@ -12,8 +13,8 @@ from rql import RQLHelper ...@@ -12,8 +13,8 @@ from rql import RQLHelper
from cubicweb import Binary, UnknownProperty, UnknownEid from cubicweb import Binary, UnknownProperty, UnknownEid
from cubicweb.vregistry import VRegistry, ObjectNotFound, NoSelectableObject from cubicweb.vregistry import VRegistry, ObjectNotFound, NoSelectableObject
from cubicweb.rtags import RTAGS
_ = unicode
def use_interfaces(obj): def use_interfaces(obj):
"""return interfaces used by the given object by searchinf for implements """return interfaces used by the given object by searchinf for implements
...@@ -122,9 +123,10 @@ class CubicWebRegistry(VRegistry): ...@@ -122,9 +123,10 @@ class CubicWebRegistry(VRegistry):
for appobjects in objects.itervalues(): for appobjects in objects.itervalues():
for appobject in appobjects: for appobject in appobjects:
appobject.vreg_initialization_completed() appobject.vreg_initialization_completed()
from cubicweb.rtags import RTAGS # don't check rtags if we don't want to cleanup_interface_sobjects
for rtag in RTAGS: for rtag in RTAGS:
rtag.init(self.schema) rtag.init(self.schema,
check=self.config.cleanup_interface_sobjects)
def initialization_completed(self): def initialization_completed(self):
# clear etype cache if you don't want to run into deep weirdness # clear etype cache if you don't want to run into deep weirdness
......
...@@ -77,6 +77,11 @@ def cleanup_sys_modules(config): ...@@ -77,6 +77,11 @@ def cleanup_sys_modules(config):
if mod.__file__.startswith(path): if mod.__file__.startswith(path):
del sys.modules[name] del sys.modules[name]
break break
# fresh rtags
from cubicweb import rtags
from cubicweb.web import uicfg
rtags.RTAGS[:] = []
reload(uicfg)
def generate_schema_pot(w, cubedir=None): def generate_schema_pot(w, cubedir=None):
"""generate a pot file with schema specific i18n messages """generate a pot file with schema specific i18n messages
......
...@@ -30,7 +30,7 @@ class RelationTags(object): ...@@ -30,7 +30,7 @@ class RelationTags(object):
self._allowed_values = allowed_values self._allowed_values = allowed_values
self._initfunc = initfunc self._initfunc = initfunc
register_rtag(self) register_rtag(self)
def __repr__(self): def __repr__(self):
return repr(self._tagdefs) return repr(self._tagdefs)
...@@ -52,14 +52,16 @@ class RelationTags(object): ...@@ -52,14 +52,16 @@ class RelationTags(object):
keys.remove((rtype, tagged, stype, '*')) keys.remove((rtype, tagged, stype, '*'))
return keys return keys
def init(self, schema): def init(self, schema, check=True):
# XXX check existing keys against schema # XXX check existing keys against schema
for (rtype, tagged, stype, otype), value in self._tagdefs.items(): if check:
for ertype in (stype, rtype, otype): for (rtype, tagged, stype, otype), value in self._tagdefs.items():
if ertype != '*' and not ertype in schema: for ertype in (stype, rtype, otype):
self.warning('removing rtag %s: %s, %s undefined in schema', if ertype != '*' and not ertype in schema:
(stype, rtype, otype, tagged), value, ertype) self.warning('removing rtag %s: %s, %s undefined in schema',
self.del_rtag(stype, rtype, otype, tagged) (stype, rtype, otype, tagged), value, ertype)
self.del_rtag(stype, rtype, otype, tagged)
break
if self._initfunc is not None: if self._initfunc is not None:
for eschema in schema.entities(): for eschema in schema.entities():
for rschema, tschemas, role in eschema.relation_definitions(True): for rschema, tschemas, role in eschema.relation_definitions(True):
......
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