21 |
21 |
22 SKIP_TYPES = set() |
22 SKIP_TYPES = set() |
23 SKIP_TYPES.update(META_RELATIONS_TYPES) |
23 SKIP_TYPES.update(META_RELATIONS_TYPES) |
24 SKIP_TYPES.update(SCHEMA_TYPES) |
24 SKIP_TYPES.update(SCHEMA_TYPES) |
25 |
25 |
|
26 def skip_types(req): |
|
27 if int(req.form.get('skipmeta', True)): |
|
28 return schema.SKIP_TYPES |
|
29 return () |
|
30 |
26 class ViewSchemaAction(action.Action): |
31 class ViewSchemaAction(action.Action): |
27 id = 'schema' |
32 id = 'schema' |
28 __select__ = yes() |
33 __select__ = yes() |
29 |
34 |
30 title = _("site schema") |
35 title = _("site schema") |
61 |
66 |
62 class CWETypePrimaryView(tabs.TabsMixin, primary.PrimaryView): |
67 class CWETypePrimaryView(tabs.TabsMixin, primary.PrimaryView): |
63 __select__ = implements('CWEType') |
68 __select__ = implements('CWEType') |
64 title = _('in memory entity schema') |
69 title = _('in memory entity schema') |
65 main_related_section = False |
70 main_related_section = False |
66 tabs = [_('cwetype-schema-text'), _('cwetype-schema-image'), |
71 tabs = [_('cwetype-schema-text'), _('cwetype-schema-image'), |
67 _('cwetype-schema-permissions'), _('cwetype-workflow')] |
72 _('cwetype-schema-permissions'), _('cwetype-workflow')] |
68 default_tab = 'cwetype-schema-text' |
73 default_tab = 'cwetype-schema-text' |
69 |
74 |
70 def render_entity(self, entity): |
75 def render_entity(self, entity): |
71 self.render_entity_title(entity) |
76 self.render_entity_title(entity) |
130 |
135 |
131 def cell_call(self, row, col): |
136 def cell_call(self, row, col): |
132 entity = self.entity(row, col) |
137 entity = self.entity(row, col) |
133 self.w(u'<h2>%s</h2>' % _('Add permissions')) |
138 self.w(u'<h2>%s</h2>' % _('Add permissions')) |
134 rset = self.req.execute('Any P WHERE X add_permission P, ' |
139 rset = self.req.execute('Any P WHERE X add_permission P, ' |
135 'X eid %(x)s', |
140 'X eid %(x)s', |
136 {'x': entity.eid}) |
141 {'x': entity.eid}) |
137 self.wview('outofcontext', rset, 'null') |
142 self.wview('outofcontext', rset, 'null') |
138 self.w(u'<h2>%s</h2>' % _('Read permissions')) |
143 self.w(u'<h2>%s</h2>' % _('Read permissions')) |
139 rset = self.req.execute('Any P WHERE X read_permission P, ' |
144 rset = self.req.execute('Any P WHERE X read_permission P, ' |
140 'X eid %(x)s', |
145 'X eid %(x)s', |
141 {'x': entity.eid}) |
146 {'x': entity.eid}) |
142 self.wview('outofcontext', rset, 'null') |
147 self.wview('outofcontext', rset, 'null') |
143 self.w(u'<h2>%s</h2>' % _('Update permissions')) |
148 self.w(u'<h2>%s</h2>' % _('Update permissions')) |
144 rset = self.req.execute('Any P WHERE X update_permission P, ' |
149 rset = self.req.execute('Any P WHERE X update_permission P, ' |
145 'X eid %(x)s', |
150 'X eid %(x)s', |
146 {'x': entity.eid}) |
151 {'x': entity.eid}) |
147 self.wview('outofcontext', rset, 'null') |
152 self.wview('outofcontext', rset, 'null') |
148 self.w(u'<h2>%s</h2>' % _('Delete permissions')) |
153 self.w(u'<h2>%s</h2>' % _('Delete permissions')) |
149 rset = self.req.execute('Any P WHERE X delete_permission P, ' |
154 rset = self.req.execute('Any P WHERE X delete_permission P, ' |
150 'X eid %(x)s', |
155 'X eid %(x)s', |
151 {'x': entity.eid}) |
156 {'x': entity.eid}) |
152 self.wview('outofcontext', rset, 'null') |
157 self.wview('outofcontext', rset, 'null') |
153 |
158 |
154 class CWETypeSWorkflowView(EntityView): |
159 class CWETypeSWorkflowView(EntityView): |
155 id = 'cwetype-workflow' |
160 id = 'cwetype-workflow' |
215 id = 'schemagraph' |
220 id = 'schemagraph' |
216 content_type = 'image/png' |
221 content_type = 'image/png' |
217 |
222 |
218 def _generate(self, tmpfile): |
223 def _generate(self, tmpfile): |
219 """display global schema information""" |
224 """display global schema information""" |
220 skipmeta = not int(self.req.form.get('withmeta', 0)) |
|
221 visitor = FullSchemaVisitor(self.req, self.schema, |
225 visitor = FullSchemaVisitor(self.req, self.schema, |
222 skiptypes=skipmeta and SKIP_TYPES or ()) |
226 skiptypes=skip_types(self.req)) |
223 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
227 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
224 |
228 |
225 class CWETypeSchemaImageView(TmpFileViewMixin, EntityView): |
229 class CWETypeSchemaImageView(TmpFileViewMixin, EntityView): |
226 id = 'schemagraph' |
230 id = 'schemagraph' |
227 __select__ = implements('CWEType') |
231 __select__ = implements('CWEType') |
229 |
233 |
230 def _generate(self, tmpfile): |
234 def _generate(self, tmpfile): |
231 """display schema information for an entity""" |
235 """display schema information for an entity""" |
232 entity = self.entity(self.row, self.col) |
236 entity = self.entity(self.row, self.col) |
233 eschema = self.vreg.schema.eschema(entity.name) |
237 eschema = self.vreg.schema.eschema(entity.name) |
234 skipmeta = not int(self.req.form.get('withmeta', 0)) |
|
235 visitor = OneHopESchemaVisitor(self.req, eschema, |
238 visitor = OneHopESchemaVisitor(self.req, eschema, |
236 skiptypes=skipmeta and SKIP_TYPES or ()) |
239 skiptypes=skip_types(self.req)) |
237 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
240 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
238 |
241 |
239 class CWRTypeSchemaImageView(CWETypeSchemaImageView): |
242 class CWRTypeSchemaImageView(CWETypeSchemaImageView): |
240 __select__ = implements('CWRType') |
243 __select__ = implements('CWRType') |
241 |
244 |