# HG changeset patch # User David Douard # Date 1415827135 -3600 # Node ID 2ddeece8480834f4ea91934aa716f14f564c5d4a # Parent 1d1afe3b5081faf297b3d7a50ba3b019ab6b20ca [web] partial backout of #8391bf718485 to restore RelatedObjectsVComponent Apparently the intended deprecation did not work, and this component is used in at least the tracker cube. diff -r 1d1afe3b5081 -r 2ddeece84808 web/component.py --- a/web/component.py Thu Nov 13 10:38:39 2014 +0100 +++ b/web/component.py Wed Nov 12 22:18:55 2014 +0100 @@ -701,3 +701,29 @@ def entity_call(self, entity, view=None): raise NotImplementedError() +class RelatedObjectsVComponent(EntityVComponent): + """a section to display some related entities""" + __select__ = EntityVComponent.__select__ & partial_has_related_entities() + + vid = 'list' + # to be defined in concrete classes + rtype = title = None + + def rql(self): + """override this method if you want to use a custom rql query""" + return None + + def cell_call(self, row, col, view=None): + rql = self.rql() + if rql is None: + entity = self.cw_rset.get_entity(row, col) + rset = entity.related(self.rtype, role(self)) + else: + eid = self.cw_rset[row][col] + rset = self._cw.execute(self.rql(), {'x': eid}) + if not rset.rowcount: + return + self.w(u'
' % self.cssclass) + self.w(u'

%s

\n' % self._cw._(self.title).capitalize()) + self.wview(self.vid, rset) + self.w(u'
')