Recursively get the type of views

View can inherit inheriting view if the model is different, so the validation
must retrieve recursively the RNG type.

issue5153
review15841002
This commit is contained in:
Cédric Krier
2015-12-13 14:53:22 +01:00
parent 551b83e964
commit e09cc7780b
+7 -2
View File
@@ -128,6 +128,12 @@ class View(ModelSQL, ModelView):
cls._get_rng_cache.set(key, rng)
return rng
@property
def rng_type(self):
if self.inherit:
return self.inherit.rng_type
return self.type
@classmethod
def validate(cls, views):
super(View, cls).validate(views)
@@ -145,8 +151,7 @@ class View(ModelSQL, ModelView):
tree = etree.fromstring(xml)
if hasattr(etree, 'RelaxNG'):
rng_type = view.inherit.type if view.inherit else view.type
validator = etree.RelaxNG(etree=cls.get_rng(rng_type))
validator = etree.RelaxNG(etree=cls.get_rng(view.rng_type))
if not validator.validate(tree):
error_log = reduce(lambda x, y: str(x) + '\n' + str(y),
validator.error_log.filter_from_errors())