fix some rtags pb on i18n catalog generation tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 13 May 2009 09:09:22 +0200
branchtls-sprint
changeset 1769 fb91d2b8a441
parent 1768 b59b7c422a8a
child 1770 8bd788149f85
fix some rtags pb on i18n catalog generation
cwvreg.py
devtools/devctl.py
rtags.py
--- a/cwvreg.py	Wed May 13 08:41:23 2009 +0200
+++ b/cwvreg.py	Wed May 13 09:09:22 2009 +0200
@@ -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 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 @@
                 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
--- a/devtools/devctl.py	Wed May 13 08:41:23 2009 +0200
+++ b/devtools/devctl.py	Wed May 13 09:09:22 2009 +0200
@@ -77,6 +77,11 @@
             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
--- a/rtags.py	Wed May 13 08:41:23 2009 +0200
+++ b/rtags.py	Wed May 13 09:09:22 2009 +0200
@@ -30,7 +30,7 @@
             self._allowed_values = allowed_values
         self._initfunc = initfunc
         register_rtag(self)
-        
+
     def __repr__(self):
         return repr(self._tagdefs)
 
@@ -52,14 +52,16 @@
                 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):