--- a/web/views/schema.py Thu Apr 30 00:41:10 2009 +0200
+++ b/web/views/schema.py Thu Apr 30 00:41:52 2009 +0200
@@ -16,7 +16,7 @@
from cubicweb.view import EntityView, StartupView
from cubicweb.common.uilib import ureport_as_html
from cubicweb.web import uicfg, action
-from cubicweb.web.views import TmpFileViewMixin, baseviews
+from cubicweb.web.views import TmpFileViewMixin, primary, baseviews
uicfg.rcategories.tag_relation('primary', ('CWPermission', 'require_group', '*'), 'subject')
@@ -33,6 +33,11 @@
uicfg.rmode.tag_relation('link', ('*', 'from_entity', 'CWEType'), 'object')
uicfg.rmode.tag_relation('link', ('*', 'to_entity', 'CWEType'), 'object')
+for attr in ('name', 'meta', 'final'):
+ uicfg.rdisplay.tag_attribute({}, 'CWRType', attr)
+for attr in ('name', 'meta', 'final', 'symetric', 'inlined'):
+ uicfg.rdisplay.tag_attribute({}, 'CWRType', attr)
+
class ViewSchemaAction(action.Action):
id = 'schema'
@@ -48,25 +53,13 @@
# schema entity types views ###################################################
-class _SchemaEntityPrimaryView(baseviews.PrimaryView):
- show_attr_label = False
+class CWRDEFPrimaryView(primary.PrimaryView):
+ __select__ = implements('CWAttribute', 'CWRelation')
cache_max_age = 60*60*2 # stay in http cache for 2 hours by default
def content_title(self, entity):
return html_escape(entity.dc_long_title())
-class CWETypePrimaryView(_SchemaEntityPrimaryView):
- __select__ = implements('CWEType')
- skip_attrs = _SchemaEntityPrimaryView.skip_attrs + ('name', 'meta', 'final')
-
-class CWRTypePrimaryView(_SchemaEntityPrimaryView):
- __select__ = implements('CWRType')
- skip_attrs = _SchemaEntityPrimaryView.skip_attrs + ('name', 'meta', 'final',
- 'symetric', 'inlined')
-
-class ErdefPrimaryView(_SchemaEntityPrimaryView):
- __select__ = implements('CWAttribute', 'CWRelation')
- show_attr_label = True
class CWETypeOneLineView(baseviews.OneLineView):
__select__ = implements('CWEType')
@@ -82,13 +75,15 @@
# in memory schema views (yams class instances) ###############################
+SKIPPED_RELS = ('is', 'is_instance_of', 'identity', 'created_by', 'owned_by',
+ 'has_text',)
-class CWETypeSchemaView(CWETypePrimaryView):
+class CWETypeSchemaView(primary.PrimaryView):
id = 'eschema'
+ __select__ = implements('CWEType')
title = _('in memory entity schema')
main_related_section = False
- skip_rels = ('is', 'is_instance_of', 'identity', 'created_by', 'owned_by',
- 'has_text',)
+ skip_rels = SKIPPED_RELS
def render_entity_attributes(self, entity, siderelations):
super(CWETypeSchemaView, self).render_entity_attributes(entity, siderelations)
@@ -102,8 +97,9 @@
html_escape(self.req._('graphical schema for %s') % entity.name)))
-class CWRTypeSchemaView(CWRTypePrimaryView):
+class CWRTypeSchemaView(primary.PrimaryView):
id = 'eschema'
+ __select__ = implements('CWRType')
title = _('in memory relation schema')
main_related_section = False
@@ -198,8 +194,9 @@
class SchemaImageView(TmpFileViewMixin, StartupView):
id = 'schemagraph'
+
content_type = 'image/png'
- skip_rels = ('owned_by', 'created_by', 'identity', 'is', 'is_instance_of')
+ skip_rels = SKIPPED_RELS
def _generate(self, tmpfile):
"""display global schema information"""
skipmeta = not int(self.req.form.get('withmeta', 0))
@@ -209,9 +206,10 @@
class CWETypeSchemaImageView(TmpFileViewMixin, EntityView):
id = 'eschemagraph'
+ __select__ = implements('CWEType')
+
content_type = 'image/png'
- __select__ = implements('CWEType')
- skip_rels = ('owned_by', 'created_by', 'identity', 'is', 'is_instance_of')
+ skip_rels = SKIPPED_RELS
def _generate(self, tmpfile):
"""display schema information for an entity"""