[view] fix TypeError when calling req.view('vid', entity=entity) (closes #1947474) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 22 Sep 2011 17:20:41 +0200
branchstable
changeset 7833 f19e3203dff6
parent 7832 953f224357af
child 7834 258fc0b4a1e0
[view] fix TypeError when calling req.view('vid', entity=entity) (closes #1947474)
view.py
--- a/view.py	Thu Sep 22 17:20:38 2011 +0200
+++ b/view.py	Thu Sep 22 17:20:41 2011 +0200
@@ -375,7 +375,19 @@
 
     def call(self, **kwargs):
         if self.cw_rset is None:
-            self.entity_call(self.cw_extra_kwargs.pop('entity'))
+            # * cw_extra_kwargs is the place where extra selection arguments are
+            #   stored
+            # * when calling req.view('somevid', entity=entity), 'entity' ends
+            #   up in cw_extra_kwargs and kwargs
+            #
+            # handle that to avoid a TypeError with a sanity check
+            #
+            # Notice that could probably be avoided by handling entity_call in
+            # .render
+            entity = self.cw_extra_kwargs.pop('entity')
+            if 'entity' in kwargs:
+                assert kwargs.pop('entity') is entity
+            self.entity_call(entity, **kwargs)
         else:
             super(EntityView, self).call(**kwargs)