# HG changeset patch # User Sylvain Thénault # Date 1273659528 -7200 # Node ID ceea458025b9786d34cd5e8cfa0252c3a87f9db7 # Parent 4b557751572294693b5637901a0c8872c74dd4fc [web] unify list views call arguments: use subvid to specify the view to use for each item diff -r 4b5577515722 -r ceea458025b9 web/views/baseviews.py --- a/web/views/baseviews.py Wed May 12 12:17:46 2010 +0200 +++ b/web/views/baseviews.py Wed May 12 12:18:48 2010 +0200 @@ -21,13 +21,13 @@ * primary, sidebox * oneline, incontext, outofcontext, text * list - +""" -""" __docformat__ = "restructuredtext en" _ = unicode from datetime import timedelta +from warnings import warn from rql import nodes @@ -308,6 +308,18 @@ __regid__ = 'simplelist' redirect_vid = 'incontext' + def call(self, subvid=None, **kwargs): + """display a list of entities by calling their view + + :param listid: the DOM id to use for the root element + """ + if subvid is None and 'vid' in kwargs: + warn("should give a 'subvid' argument instead of 'vid'", + DeprecationWarning, stacklevel=2) + else: + kwargs['vid'] = subvid + return super(SimpleListView, self).call(**kwargs) + class SameETypeListView(EntityView): """list of entities of the same type, when asked explicitly for same etype list @@ -344,10 +356,15 @@ __regid__ = 'csv' redirect_vid = 'incontext' - def call(self, **kwargs): + def call(self, subvid=None, **kwargs): + if subvid is None and 'vid' in kwargs: + warn("should give a 'subvid' argument instead of 'vid'", + DeprecationWarning, stacklevel=2) + else: + kwargs['vid'] = subvid rset = self.cw_rset for i in xrange(len(rset)): - self.cell_call(i, 0, vid=kwargs.get('vid')) + self.cell_call(i, 0, **kwargs) if i < rset.rowcount-1: self.w(u", ")