--- a/web/views/primary.py Wed Sep 15 11:13:17 2010 +0200
+++ b/web/views/primary.py Wed Sep 15 15:00:04 2010 +0200
@@ -336,6 +336,28 @@
if url:
self.w(u'<a href="%s">%s</a>' % (url, url))
+class AttributeView(EntityView):
+ """use this view on an entity as an alternative to more sophisticated
+ views such as reledit.
+
+ Ex. usage:
+
+ uicfg.primaryview_display_ctrl.tag_attribute(('Foo', 'bar'), {'vid': 'attribute'})
+ """
+ __regid__ = 'attribute'
+ __select__ = EntityView.__select__ & match_kwargs('rtype')
+
+ def cell_call(self, row, col, rtype, **kwargs):
+ entity = self.cw_rset.get_entity(row, col)
+ if self._cw.vreg.schema.rschema(rtype).final:
+ self.w(entity.printable_value(rtype))
+ else:
+ dispctrl = uicfg.primaryview_display_ctrl.etype_get(
+ entity.e_schema, rtype, kwargs['role'], '*')
+ rset = entity.related(rtype, role)
+ if rset:
+ self.wview('autolimited', rset, initargs={'dispctrl': dispctrl})
+
## default primary ui configuration ###########################################