RNG Tests
bzr revid: fp@tinyerp.com-57a3e9e01e4bc725740257eaf2a28af169eebac8
This commit is contained in:
parent
fb51586de8
commit
da97f83b0b
|
@ -28,16 +28,23 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from osv import fields,osv
|
from osv import fields,osv
|
||||||
from xml import dom
|
from lxml import etree
|
||||||
|
import tools
|
||||||
|
import netsvc
|
||||||
|
import os
|
||||||
|
|
||||||
def _check_xml(self, cr, uid, ids):
|
def _check_xml(self, cr, uid, ids, context={}):
|
||||||
try:
|
for view in self.browse(cr, uid, ids, context):
|
||||||
cr.execute('select arch from ir_ui_view where id in ('+','.join(map(str,ids))+')')
|
eview = etree.fromstring(view.arch)
|
||||||
for row in cr.fetchall():
|
frng = tools.file_open(os.path.join('base','rng',view.type+'.rng'))
|
||||||
doc = dom.minidom.parseString(row[0])
|
relaxng = etree.RelaxNG(file=frng)
|
||||||
return True
|
if not relaxng.validate(eview):
|
||||||
except Exception, e:
|
logger = netsvc.Logger()
|
||||||
return False
|
logger.notifyChannel('init', netsvc.LOG_ERROR, 'The view do not fit the required schema !')
|
||||||
|
logger.notifyChannel('init', netsvc.LOG_ERROR, relaxng.error_log.last_error)
|
||||||
|
print view.arch
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
class view(osv.osv):
|
class view(osv.osv):
|
||||||
_name = 'ir.ui.view'
|
_name = 'ir.ui.view'
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rng:grammar xmlns:rng="http://relaxng.org/ns/structure/1.0">
|
||||||
|
<rng:define name="any">
|
||||||
|
<rng:element>
|
||||||
|
<rng:anyName/>
|
||||||
|
<rng:zeroOrMore>
|
||||||
|
<rng:choice>
|
||||||
|
<rng:attribute>
|
||||||
|
<rng:anyName/>
|
||||||
|
</rng:attribute>
|
||||||
|
<rng:text/>
|
||||||
|
<rng:ref name="any"/>
|
||||||
|
</rng:choice>
|
||||||
|
</rng:zeroOrMore>
|
||||||
|
</rng:element>
|
||||||
|
</rng:define>
|
||||||
|
|
||||||
|
<rng:start>
|
||||||
|
<rng:ref name="any" />
|
||||||
|
</rng:start>
|
||||||
|
</rng:grammar>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rng:grammar xmlns:rng="http://relaxng.org/ns/structure/1.0">
|
||||||
|
<rng:define name="any">
|
||||||
|
<rng:element>
|
||||||
|
<rng:anyName/>
|
||||||
|
<rng:zeroOrMore>
|
||||||
|
<rng:choice>
|
||||||
|
<rng:attribute>
|
||||||
|
<rng:anyName/>
|
||||||
|
</rng:attribute>
|
||||||
|
<rng:text/>
|
||||||
|
<rng:ref name="any"/>
|
||||||
|
</rng:choice>
|
||||||
|
</rng:zeroOrMore>
|
||||||
|
</rng:element>
|
||||||
|
</rng:define>
|
||||||
|
|
||||||
|
<rng:start>
|
||||||
|
<rng:ref name="any" />
|
||||||
|
</rng:start>
|
||||||
|
</rng:grammar>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rng:grammar xmlns:rng="http://relaxng.org/ns/structure/1.0">
|
||||||
|
<rng:define name="any">
|
||||||
|
<rng:element>
|
||||||
|
<rng:anyName/>
|
||||||
|
<rng:zeroOrMore>
|
||||||
|
<rng:choice>
|
||||||
|
<rng:attribute>
|
||||||
|
<rng:anyName/>
|
||||||
|
</rng:attribute>
|
||||||
|
<rng:text/>
|
||||||
|
<rng:ref name="any"/>
|
||||||
|
</rng:choice>
|
||||||
|
</rng:zeroOrMore>
|
||||||
|
</rng:element>
|
||||||
|
</rng:define>
|
||||||
|
|
||||||
|
<rng:start>
|
||||||
|
<rng:ref name="any" />
|
||||||
|
</rng:start>
|
||||||
|
</rng:grammar>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<rng:grammar xmlns:rng="http://relaxng.org/ns/structure/1.0">
|
||||||
|
<rng:define name="any">
|
||||||
|
<rng:element>
|
||||||
|
<rng:anyName/>
|
||||||
|
<rng:zeroOrMore>
|
||||||
|
<rng:choice>
|
||||||
|
<rng:attribute>
|
||||||
|
<rng:anyName/>
|
||||||
|
</rng:attribute>
|
||||||
|
<rng:text/>
|
||||||
|
<rng:ref name="any"/>
|
||||||
|
</rng:choice>
|
||||||
|
</rng:zeroOrMore>
|
||||||
|
</rng:element>
|
||||||
|
</rng:define>
|
||||||
|
|
||||||
|
<rng:start>
|
||||||
|
<rng:ref name="any" />
|
||||||
|
</rng:start>
|
||||||
|
</rng:grammar>
|
Loading…
Reference in New Issue