--- a/web/views/schema.py Tue Apr 28 10:11:08 2009 +0200
+++ b/web/views/schema.py Tue Apr 28 11:22:31 2009 +0200
@@ -15,49 +15,46 @@
from cubicweb.schemaviewer import SchemaViewer
from cubicweb.view import EntityView, StartupView
from cubicweb.common.uilib import ureport_as_html
-from cubicweb.web.action import Action
-from cubicweb.web.views import baseviews
-from cubicweb.web.views import TmpFileViewMixin
-from cubicweb.web.views.editforms import AutomaticEntityForm
-from cubicweb.web.views.boxes import EditBox
+from cubicweb.web import uicfg, action
+from cubicweb.web.views import TmpFileViewMixin, baseviews
-AutomaticEntityForm.rcategories.set_rtag('primary', 'require_group', 'subject', 'CWPermission')
-AutomaticEntityForm.rcategories.set_rtag('generated', 'final', 'subject', 'EEtype')
-AutomaticEntityForm.rcategories.set_rtag('generated', 'final', 'subject', 'ERtype')
-AutomaticEntityForm.rinlined.set_rtag(True, 'relation_type', 'subject', 'CWRelation')
-AutomaticEntityForm.rinlined.set_rtag(True, 'from_entity', 'subject', 'CWRelation')
-AutomaticEntityForm.rinlined.set_rtag(True, 'to_entity', 'subject', 'CWRelation')
-AutomaticEntityForm.rwidgets.set_rtag('StringWidget', 'expression', 'subject', 'RQLExpression')
+uicfg.rcategories.set_rtag('primary', 'require_group', 'subject', 'CWPermission')
+uicfg.rcategories.set_rtag('generated', 'final', 'subject', 'EEtype')
+uicfg.rcategories.set_rtag('generated', 'final', 'subject', 'ERtype')
+uicfg.rinlined.set_rtag(True, 'relation_type', 'subject', 'CWRelation')
+uicfg.rinlined.set_rtag(True, 'from_entity', 'subject', 'CWRelation')
+uicfg.rinlined.set_rtag(True, 'to_entity', 'subject', 'CWRelation')
+uicfg.rwidgets.set_rtag('StringWidget', 'expression', 'subject', 'RQLExpression')
-EditBox.rmode.set_rtag('create', 'state_of', 'object', 'CWEType')
-EditBox.rmode.set_rtag('create', 'transition_of', 'object', 'CWEType')
-EditBox.rmode.set_rtag('create', 'relation_type', 'object', 'CWRType')
-EditBox.rmode.set_rtag('link', 'from_entity', 'object', 'CWEType')
-EditBox.rmode.set_rtag('link', 'to_entity', 'object', 'CWEType')
+uicfg.rmode.set_rtag('create', 'state_of', 'object', 'CWEType')
+uicfg.rmode.set_rtag('create', 'transition_of', 'object', 'CWEType')
+uicfg.rmode.set_rtag('create', 'relation_type', 'object', 'CWRType')
+uicfg.rmode.set_rtag('link', 'from_entity', 'object', 'CWEType')
+uicfg.rmode.set_rtag('link', 'to_entity', 'object', 'CWEType')
-class ViewSchemaAction(Action):
+class ViewSchemaAction(action.Action):
id = 'schema'
__select__ = yes()
-
+
title = _("site schema")
category = 'siteactions'
order = 30
-
+
def url(self):
return self.build_url(self.id)
-
-
+
+
# schema entity types views ###################################################
class _SchemaEntityPrimaryView(baseviews.PrimaryView):
show_attr_label = False
- cache_max_age = 60*60*2 # stay in http cache for 2 hours by default
-
+ 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')
@@ -73,7 +70,7 @@
class CWETypeOneLineView(baseviews.OneLineView):
__select__ = implements('CWEType')
-
+
def cell_call(self, row, col, **kwargs):
entity = self.entity(row, col)
final = entity.final
@@ -92,7 +89,7 @@
main_related_section = False
skip_rels = ('is', 'is_instance_of', 'identity', 'created_by', 'owned_by',
'has_text',)
-
+
def render_entity_attributes(self, entity, siderelations):
super(CWETypeSchemaView, self).render_entity_attributes(entity, siderelations)
eschema = self.vreg.schema.eschema(entity.name)
@@ -120,7 +117,7 @@
self.w(u'<img src="%s" alt="%s"/>' % (
html_escape(entity.absolute_url(vid='eschemagraph')),
html_escape(self.req._('graphical schema for %s') % entity.name)))
-
+
# schema images ###############################################################
@@ -143,11 +140,11 @@
self.nextcolor = cycle( ('#aa0000', '#00aa00', '#0000aa',
'#000000', '#888888') ).next
self.req = req
-
+
def display_attr(self, rschema):
return not rschema.meta and (rschema.has_local_role('read')
or rschema.has_perm(self.req, 'read'))
-
+
# XXX remove this method once yams > 0.20 is out
def node_properties(self, eschema):
"""return default DOT drawing options for an entity schema"""
@@ -168,7 +165,7 @@
# + 1 line going to the closest edge spline point)
kwargs['decorate'] = 'false'
return kwargs
-
+
class RestrictedSchemaVisitorMiIn:
def __init__(self, req, *args, **kwargs):
@@ -177,12 +174,12 @@
self.__parent = self.__class__.__bases__[1]
self.__parent.__init__(self, *args, **kwargs)
self.req = req
-
+
def nodes(self):
for etype, eschema in self.__parent.nodes(self):
if eschema.has_local_role('read') or eschema.has_perm(self.req, 'read'):
yield eschema.type, eschema
-
+
def edges(self):
for setype, oetype, rschema in self.__parent.edges(self):
if rschema.has_local_role('read') or rschema.has_perm(self.req, 'read'):
@@ -215,7 +212,7 @@
content_type = 'image/png'
__select__ = implements('CWEType')
skip_rels = ('owned_by', 'created_by', 'identity', 'is', 'is_instance_of')
-
+
def _generate(self, tmpfile):
"""display schema information for an entity"""
entity = self.entity(self.row, self.col)
@@ -226,7 +223,7 @@
class CWRTypeSchemaImageView(CWETypeSchemaImageView):
__select__ = implements('CWRType')
-
+
def _generate(self, tmpfile):
"""display schema information for an entity"""
entity = self.entity(self.row, self.col)