author | sylvain.thenault@logilab.fr |
Tue, 12 May 2009 11:56:12 +0200 | |
branch | tls-sprint |
changeset 1739 | 78b0819162a8 |
parent 1725 | d15406d17803 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
0 | 1 |
"""Specific views for schema related entities |
2 |
||
3 |
:organization: Logilab |
|
787 | 4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 |
""" |
|
7 |
__docformat__ = "restructuredtext en" |
|
8 |
||
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
9 |
from itertools import cycle |
0 | 10 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
11 |
from logilab.mtconverter import html_escape |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
12 |
from yams import schema2dot as s2d |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
13 |
|
1132 | 14 |
from cubicweb.selectors import implements, yes |
0 | 15 |
from cubicweb.schemaviewer import SchemaViewer |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
16 |
from cubicweb.view import EntityView, StartupView |
1556 | 17 |
from cubicweb.common import tags, uilib |
1739 | 18 |
from cubicweb.web import action |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
19 |
from cubicweb.web.views import TmpFileViewMixin, primary, baseviews |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
20 |
|
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
21 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
22 |
class ViewSchemaAction(action.Action): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
23 |
id = 'schema' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
24 |
__select__ = yes() |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
25 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
26 |
title = _("site schema") |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
27 |
category = 'siteactions' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
28 |
order = 30 |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
29 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
30 |
def url(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
31 |
return self.build_url(self.id) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
32 |
|
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
33 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
34 |
# schema entity types views ################################################### |
0 | 35 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
36 |
class CWRDEFPrimaryView(primary.PrimaryView): |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
37 |
__select__ = implements('CWAttribute', 'CWRelation') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
38 |
cache_max_age = 60*60*2 # stay in http cache for 2 hours by default |
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
39 |
|
1720 | 40 |
def render_entity_title(self, entity): |
41 |
self.w(u'<h1><span class="etype">%s</span> %s</h1>' |
|
42 |
% (entity.dc_type().capitalize(), |
|
1723 | 43 |
html_escape(entity.dc_long_title()))) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
44 |
|
0 | 45 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
46 |
class CWETypeOneLineView(baseviews.OneLineView): |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
47 |
__select__ = implements('CWEType') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
48 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
49 |
def cell_call(self, row, col, **kwargs): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
50 |
entity = self.entity(row, col) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
51 |
final = entity.final |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
52 |
if final: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
53 |
self.w(u'<em class="finalentity">') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
54 |
super(CWETypeOneLineView, self).cell_call(row, col, **kwargs) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
55 |
if final: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
56 |
self.w(u'</em>') |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
57 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
58 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
59 |
# in memory schema views (yams class instances) ############################### |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
60 |
SKIPPED_RELS = ('is', 'is_instance_of', 'identity', 'created_by', 'owned_by', |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
61 |
'has_text',) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
62 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
63 |
class CWETypeSchemaView(primary.PrimaryView): |
0 | 64 |
id = 'eschema' |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
65 |
__select__ = implements('CWEType') |
0 | 66 |
title = _('in memory entity schema') |
67 |
main_related_section = False |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
68 |
skip_rels = SKIPPED_RELS |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
69 |
|
1556 | 70 |
def render_entity_attributes(self, entity): |
71 |
super(CWETypeSchemaView, self).render_entity_attributes(entity) |
|
0 | 72 |
eschema = self.vreg.schema.eschema(entity.name) |
73 |
viewer = SchemaViewer(self.req) |
|
74 |
layout = viewer.visit_entityschema(eschema, skiprels=self.skip_rels) |
|
1556 | 75 |
self.w(uilib.ureport_as_html(layout)) |
0 | 76 |
if not eschema.is_final(): |
1556 | 77 |
msg = self.req._('graphical schema for %s') % entity.name |
78 |
self.w(tags.img(src=entity.absolute_url(vid='eschemagraph'), |
|
79 |
alt=msg)) |
|
0 | 80 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
81 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
82 |
class CWRTypeSchemaView(primary.PrimaryView): |
0 | 83 |
id = 'eschema' |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
84 |
__select__ = implements('CWRType') |
0 | 85 |
title = _('in memory relation schema') |
86 |
main_related_section = False |
|
87 |
||
1556 | 88 |
def render_entity_attributes(self, entity): |
89 |
super(CWRTypeSchemaView, self).render_entity_attributes(entity) |
|
0 | 90 |
rschema = self.vreg.schema.rschema(entity.name) |
91 |
viewer = SchemaViewer(self.req) |
|
92 |
layout = viewer.visit_relationschema(rschema) |
|
1556 | 93 |
self.w(uilib.ureport_as_html(layout)) |
0 | 94 |
if not rschema.is_final(): |
1556 | 95 |
msg = self.req._('graphical schema for %s') % entity.name |
96 |
self.w(tags.img(src=entity.absolute_url(vid='eschemagraph'), |
|
97 |
alt=msg)) |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
98 |
|
0 | 99 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
100 |
# schema images ############################################################### |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
101 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
102 |
class ImageView(EntityView): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
103 |
__select__ = implements('CWEType') |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
104 |
id = 'image' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
105 |
title = _('image') |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
106 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
107 |
def cell_call(self, row, col): |
0 | 108 |
entity = self.entity(row, col) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
109 |
url = entity.absolute_url(vid='eschemagraph') |
0 | 110 |
self.w(u'<img src="%s" alt="%s"/>' % ( |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
111 |
html_escape(url), |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
112 |
html_escape(self.req._('graphical schema for %s') % entity.name))) |
0 | 113 |
|
114 |
||
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
115 |
class RestrictedSchemaDotPropsHandler(s2d.SchemaDotPropsHandler): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
116 |
def __init__(self, req): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
117 |
# FIXME: colors are arbitrary |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
118 |
self.nextcolor = cycle( ('#aa0000', '#00aa00', '#0000aa', |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
119 |
'#000000', '#888888') ).next |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
120 |
self.req = req |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
121 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
122 |
def display_attr(self, rschema): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
123 |
return not rschema.meta and (rschema.has_local_role('read') |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
124 |
or rschema.has_perm(self.req, 'read')) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
125 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
126 |
# XXX remove this method once yams > 0.20 is out |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
127 |
def node_properties(self, eschema): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
128 |
"""return default DOT drawing options for an entity schema""" |
1132 | 129 |
label = ['{', eschema.type, '|'] |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
130 |
label.append(r'\l'.join(rel.type for rel in eschema.subject_relations() |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
131 |
if rel.final and self.display_attr(rel))) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
132 |
label.append(r'\l}') # trailing \l ensure alignement of the last one |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
133 |
return {'label' : ''.join(label), 'shape' : "record", |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
134 |
'fontname' : "Courier", 'style' : "filled"} |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
135 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
136 |
def edge_properties(self, rschema, subjnode, objnode): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
137 |
kwargs = super(RestrictedSchemaDotPropsHandler, self).edge_properties(rschema, subjnode, objnode) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
138 |
# symetric rels are handled differently, let yams decide what's best |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
139 |
if not rschema.symetric: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
140 |
kwargs['color'] = self.nextcolor() |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
141 |
kwargs['fontcolor'] = kwargs['color'] |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
142 |
# dot label decoration is just awful (1 line underlining the label |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
143 |
# + 1 line going to the closest edge spline point) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
144 |
kwargs['decorate'] = 'false' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
145 |
return kwargs |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
146 |
|
0 | 147 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
148 |
class RestrictedSchemaVisitorMiIn: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
149 |
def __init__(self, req, *args, **kwargs): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
150 |
# hack hack hack |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
151 |
assert len(self.__class__.__bases__) == 2 |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
152 |
self.__parent = self.__class__.__bases__[1] |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
153 |
self.__parent.__init__(self, *args, **kwargs) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
154 |
self.req = req |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
155 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
156 |
def nodes(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
157 |
for etype, eschema in self.__parent.nodes(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
158 |
if eschema.has_local_role('read') or eschema.has_perm(self.req, 'read'): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
159 |
yield eschema.type, eschema |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
160 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
161 |
def edges(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
162 |
for setype, oetype, rschema in self.__parent.edges(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
163 |
if rschema.has_local_role('read') or rschema.has_perm(self.req, 'read'): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
164 |
yield setype, oetype, rschema |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
165 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
166 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
167 |
class FullSchemaVisitor(RestrictedSchemaVisitorMiIn, s2d.FullSchemaVisitor): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
168 |
pass |
0 | 169 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
170 |
class OneHopESchemaVisitor(RestrictedSchemaVisitorMiIn, s2d.OneHopESchemaVisitor): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
171 |
pass |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
172 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
173 |
class OneHopRSchemaVisitor(RestrictedSchemaVisitorMiIn, s2d.OneHopRSchemaVisitor): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
174 |
pass |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
175 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
176 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
177 |
class SchemaImageView(TmpFileViewMixin, StartupView): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
178 |
id = 'schemagraph' |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
179 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
180 |
content_type = 'image/png' |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
181 |
skip_rels = SKIPPED_RELS |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
182 |
def _generate(self, tmpfile): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
183 |
"""display global schema information""" |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
184 |
skipmeta = not int(self.req.form.get('withmeta', 0)) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
185 |
visitor = FullSchemaVisitor(self.req, self.schema, skiprels=self.skip_rels, skipmeta=skipmeta) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
186 |
s2d.schema2dot(outputfile=tmpfile, visitor=visitor, |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
187 |
prophdlr=RestrictedSchemaDotPropsHandler(self.req)) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
188 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
189 |
class CWETypeSchemaImageView(TmpFileViewMixin, EntityView): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
190 |
id = 'eschemagraph' |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
191 |
__select__ = implements('CWEType') |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
192 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
193 |
content_type = 'image/png' |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
194 |
skip_rels = SKIPPED_RELS |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
195 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
196 |
def _generate(self, tmpfile): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
197 |
"""display schema information for an entity""" |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
198 |
entity = self.entity(self.row, self.col) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
199 |
eschema = self.vreg.schema.eschema(entity.name) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
200 |
visitor = OneHopESchemaVisitor(self.req, eschema, skiprels=self.skip_rels) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
201 |
s2d.schema2dot(outputfile=tmpfile, visitor=visitor, |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
202 |
prophdlr=RestrictedSchemaDotPropsHandler(self.req)) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
203 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
204 |
class CWRTypeSchemaImageView(CWETypeSchemaImageView): |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
205 |
__select__ = implements('CWRType') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
206 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
207 |
def _generate(self, tmpfile): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
208 |
"""display schema information for an entity""" |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
209 |
entity = self.entity(self.row, self.col) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
210 |
rschema = self.vreg.schema.rschema(entity.name) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
211 |
visitor = OneHopRSchemaVisitor(self.req, rschema) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
212 |
s2d.schema2dot(outputfile=tmpfile, visitor=visitor, |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
213 |
prophdlr=RestrictedSchemaDotPropsHandler(self.req)) |