get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 16 Oct 2009 15:18:38 +0200
branchstable
changeset 3705 5cd35123866b
parent 3704 ddb10568f5f8
child 3706 f804bbd0670e
get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument)
web/views/primary.py
--- a/web/views/primary.py	Fri Oct 16 15:17:28 2009 +0200
+++ b/web/views/primary.py	Fri Oct 16 15:18:38 2009 +0200
@@ -187,7 +187,8 @@
         self.w(u'<div class="section">')
         if showlabel:
             self.w(u'<h4>%s</h4>' % self.req._(dispctrl['label']))
-        self.wview(dispctrl.get('vid', defaultvid), rset, dispctrl=dispctrl)
+        self.wview(dispctrl.get('vid', defaultvid), rset,
+                   initargs={'dispctrl': dispctrl})
         self.w(u'</div>')
 
     def _render_attribute(self, rschema, value, role='subject'):
@@ -202,12 +203,14 @@
 class RelatedView(EntityView):
     id = 'autolimited'
 
-    def call(self, dispctrl=None, **kwargs):
+    def call(self, **kwargs):
         # nb: rset retreived using entity.related with limit + 1 if any
         # because of that, we known that rset.printable_rql() will return
         # rql with no limit set anyway (since it's handled manually)
-        if dispctrl is not None:
-            limit = dispctrl.get('limit')
+        if 'dispctrl' in self.extra_kwargs:
+            limit = self.extra_kwargs['dispctrl'].get('limit')
+        else:
+            limit = None
         # if not too many entities, show them all in a list
         if limit is None or self.rset.rowcount <= limit:
             if self.rset.rowcount == 1: