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