web/views/schema.py
branchtls-sprint
changeset 1132 96752791c2b6
parent 1091 b5e253c0dd13
child 1151 b20677336ee6
equal deleted inserted replaced
1131:544609e83317 1132:96752791c2b6
     7 __docformat__ = "restructuredtext en"
     7 __docformat__ = "restructuredtext en"
     8 
     8 
     9 from itertools import cycle
     9 from itertools import cycle
    10 
    10 
    11 from logilab.mtconverter import html_escape
    11 from logilab.mtconverter import html_escape
    12 from logilab.common.graph import escape, GraphGenerator, DotBackend
       
    13 from yams import schema2dot as s2d
    12 from yams import schema2dot as s2d
    14 
    13 
    15 from cubicweb.selectors import implements, rql_condition, yes
    14 from cubicweb.selectors import implements, yes
    16 from cubicweb.schemaviewer import SchemaViewer
    15 from cubicweb.schemaviewer import SchemaViewer
    17 from cubicweb.view import EntityView, StartupView
    16 from cubicweb.view import EntityView, StartupView
    18 from cubicweb.common.uilib import ureport_as_html
    17 from cubicweb.common.uilib import ureport_as_html
    19 from cubicweb.web.action import Action
    18 from cubicweb.web.action import Action
    20 from cubicweb.web.views import baseviews
    19 from cubicweb.web.views import baseviews
   133                                      or rschema.has_perm(self.req, 'read'))
   132                                      or rschema.has_perm(self.req, 'read'))
   134     
   133     
   135     # XXX remove this method once yams > 0.20 is out
   134     # XXX remove this method once yams > 0.20 is out
   136     def node_properties(self, eschema):
   135     def node_properties(self, eschema):
   137         """return default DOT drawing options for an entity schema"""
   136         """return default DOT drawing options for an entity schema"""
   138         label = ['{',eschema.type,'|']
   137         label = ['{', eschema.type, '|']
   139         label.append(r'\l'.join(rel.type for rel in eschema.subject_relations()
   138         label.append(r'\l'.join(rel.type for rel in eschema.subject_relations()
   140                                 if rel.final and self.display_attr(rel)))
   139                                 if rel.final and self.display_attr(rel)))
   141         label.append(r'\l}') # trailing \l ensure alignement of the last one
   140         label.append(r'\l}') # trailing \l ensure alignement of the last one
   142         return {'label' : ''.join(label), 'shape' : "record",
   141         return {'label' : ''.join(label), 'shape' : "record",
   143                 'fontname' : "Courier", 'style' : "filled"}
   142                 'fontname' : "Courier", 'style' : "filled"}