web/views/owl.py
changeset 516 56fd73de1f06
parent 512 cfb8d087cba3
child 517 64402a18da5d
equal deleted inserted replaced
515:92d95b86263e 516:56fd73de1f06
   214         self.w(u'</rdf:RDF>')
   214         self.w(u'</rdf:RDF>')
   215 
   215 
   216     def cell_call(self, row, col, skiprels=(), skipmeta=True):
   216     def cell_call(self, row, col, skiprels=(), skipmeta=True):
   217         entity = self.complete_entity(row, col)
   217         entity = self.complete_entity(row, col)
   218         eschema = entity.e_schema
   218         eschema = entity.e_schema
   219         self.w(u'''<%s rdf:ID="%s">''' % (eschema, entity.name))
   219         self.w(u'<%s rdf:ID="%s">' % (eschema, entity.eid))
   220         self.w(u'<!--attributes-->')
   220         self.w(u'<!--attributes-->')
   221         for rschema, aschema in eschema.attribute_definitions():
   221         for rschema, aschema in eschema.attribute_definitions():
   222             if rschema.type in skiprels:
   222             if rschema.type in skiprels:
   223                 continue
   223                 continue
   224             if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')):
   224             if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')):
   226             aname = rschema.type
   226             aname = rschema.type
   227             if aname == 'eid':
   227             if aname == 'eid':
   228                 continue
   228                 continue
   229             attr = getattr(entity, aname)
   229             attr = getattr(entity, aname)
   230             if attr is not None:
   230             if attr is not None:
   231                 self.w(u'''<%s>%s</%s>'''% (aname, html_escape(unicode(attr)), aname))
   231                 self.w(u'<%s>%s</%s>' % (aname, html_escape(unicode(attr)), aname))
   232             
       
   233         self.w(u'<!--relations -->')
   232         self.w(u'<!--relations -->')
   234         for rschema, targetschemas, role in eschema.relation_definitions():
   233         for rschema, targetschemas, role in eschema.relation_definitions():
   235             if rschema.type in skiprels:
   234             if rschema.type in skiprels:
   236                 continue
   235                 continue
   237             if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')):
   236             if not (rschema.has_local_role('read') or rschema.has_perm(self.req, 'read')):
   238                 continue
   237                 continue
   239             if role =='object':
   238             if role == 'object':
   240                 reverse = 'reverse_%s' % rschema.type 
   239                 attr = 'reverse_%s' % rschema.type 
   241                 rel = getattr(entity, reverse)
       
   242             else:
   240             else:
   243                 rel = getattr(entity, rschema.type)
   241                 attr = rschema.type        
   244                 reverse = '%s' % rschema.type        
   242             for x in getattr(entity, tag):
   245             if rel:
   243                 self.w(u'<%s>%s %s</%s>' % (attr, x.id, x.eid, attr))
   246                 for x in rel:
   244         self.w(u'</%s>'% eschema)
   247                     if hasattr(x, 'name'):
   245 
   248                         self.w(u'''<%s>%s %s %s</%s> ''' % (reverse, targetschemas[0], html_escape(unicode(x.name)),
       
   249                                                             html_escape(unicode(x.eid)), reverse))
       
   250                     else :
       
   251                         self.w(u'''<%s>%s %s</%s> ''' % (reverse, targetschemas[0], html_escape(unicode(x.eid)), reverse))
       
   252                        
       
   253         self.w(u'''</%s>'''% eschema)
       
   254