Reviewers: ,


Please review this at http://codereview.tryton.org/446001/

Affected files:
  M trytond/ir/ui/view.py


Index: trytond/ir/ui/view.py
===================================================================

--- a/trytond/ir/ui/view.py
+++ b/trytond/ir/ui/view.py
@@ -12,6 +12,7 @@
from trytond.wizard import Wizard, StateView, StateAction, StateTransition, \
     Button
 from trytond.pool import Pool
+from trytond.cache import Cache


 class View(ModelSQL, ModelView):
@@ -70,6 +71,11 @@
     def default_module(self):
         return Transaction().context.get('module') or ''

+    @Cache('ir.ui.view.get_rng')
+    def get_rng(self, type):
+        rng_name = os.path.join(os.path.dirname(__file__), type + '.rng')
+        return etree.fromstring(open(rng_name).read())
+
     def check_xml(self, ids):
         "Check XML"
         pool = Pool()
@@ -93,11 +99,9 @@
                 continue
             tree = etree.fromstring(xml)

-            # validate the tree using RelaxNG
-            rng_name = os.path.join(os.path.dirname(__file__),
- (view.inherit and view.inherit.type or view.type) + '.rng')
             if hasattr(etree, 'RelaxNG'):
-                validator = etree.RelaxNG(file=rng_name)
+ validator = etree.RelaxNG(etree=self.get_rng(view.inherit.type
+                        if view.inherit else view.type))
                 if not validator.validate(tree):
                     logger = logging.getLogger('ir')
                     error_log = reduce(lambda x, y: str(x) + '\n' + str(y),



--
tryton-dev@googlegroups.com mailing list

Reply via email to