web/views/owl.py
branchtls-sprint
changeset 939 ad72e06320e2
parent 688 cddfbdee0eb3
parent 815 ec7460e13eee
child 984 536e421b082b
equal deleted inserted replaced
913:5dfba71b1872 939:ad72e06320e2
     1 from logilab.mtconverter import TransformError, html_escape
     1 from logilab.mtconverter import TransformError, xml_escape
     2 
     2 
     3 from cubicweb.common.view import StartupView
     3 from cubicweb.common.view import StartupView
     4 from cubicweb.common.view import EntityView
     4 from cubicweb.common.view import EntityView
     5 
     5 
     6 _ = unicode
     6 _ = unicode
   157     templatable = False
   157     templatable = False
   158     content_type = 'application/xml' # 'text/xml'
   158     content_type = 'application/xml' # 'text/xml'
   159     
   159     
   160     def call(self):
   160     def call(self):
   161         self.w(OWL_OPENING_ROOT % {'appid': self.schema.name})
   161         self.w(OWL_OPENING_ROOT % {'appid': self.schema.name})
   162         self.wview('owl', None, writeprefix=False)
       
   163         for i in xrange(self.rset.rowcount):
   162         for i in xrange(self.rset.rowcount):
   164             self.cell_call(i, 0)
   163             self.cell_call(i, 0)
   165         self.w(OWL_CLOSING_ROOT)
   164         self.w(OWL_CLOSING_ROOT)
   166 
   165 
   167     def cell_call(self, row, col, skiprels=DEFAULT_SKIP_RELS):
   166     def cell_call(self, row, col, skiprels=DEFAULT_SKIP_RELS):
   188             if aname == 'eid':
   187             if aname == 'eid':
   189                 continue
   188                 continue
   190             try:
   189             try:
   191                 attr = entity.printable_value(aname, format='text/plain')
   190                 attr = entity.printable_value(aname, format='text/plain')
   192                 if attr:
   191                 if attr:
   193                     self.w(u'<%s>%s</%s>' % (aname, html_escape(attr), aname))
   192                     self.w(u'<%s>%s</%s>' % (aname, xml_escape(attr), aname))
   194             except TransformError:
   193             except TransformError:
   195                 pass
   194                 pass
   196         self.w(u'<!--relations -->')
   195         self.w(u'<!--relations -->')
   197         for rschema, targetschemas, role in eschema.relation_definitions():
   196         for rschema, targetschemas, role in eschema.relation_definitions():
   198             if rschema.type in skiprels:
   197             if rschema.type in skiprels: