[view] fix TypeError when calling req.view('vid', entity=entity) (closes #1947474)

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changesetf19e3203dff6
branchstable
phasepublic
hiddenno
parent revision#953f224357af [sources management] nicer source management view and breadcrumbs (closes #1946329)
child revision#258fc0b4a1e0 [reledit] honore 'rvid' for attribute relations (closes #1947471)
files modified by this revision
view.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1316704841 -7200
# Thu Sep 22 17:20:41 2011 +0200
# Branch stable
# Node ID f19e3203dff6b454f9685c10d4346d8e9c2ae90a
# Parent 953f224357af83cfc5b4d8df8bca9752158aa13e
[view] fix TypeError when calling req.view('vid', entity=entity) (closes #1947474)

diff --git a/view.py b/view.py
@@ -373,11 +373,23 @@
1      __select__ = non_final_entity()
2      category = _('entityview')
3 
4      def call(self, **kwargs):
5          if self.cw_rset is None:
6 -            self.entity_call(self.cw_extra_kwargs.pop('entity'))
7 +            # * cw_extra_kwargs is the place where extra selection arguments are
8 +            #   stored
9 +            # * when calling req.view('somevid', entity=entity), 'entity' ends
10 +            #   up in cw_extra_kwargs and kwargs
11 +            #
12 +            # handle that to avoid a TypeError with a sanity check
13 +            #
14 +            # Notice that could probably be avoided by handling entity_call in
15 +            # .render
16 +            entity = self.cw_extra_kwargs.pop('entity')
17 +            if 'entity' in kwargs:
18 +                assert kwargs.pop('entity') is entity
19 +            self.entity_call(entity, **kwargs)
20          else:
21              super(EntityView, self).call(**kwargs)
22 
23      def cell_call(self, row, col, **kwargs):
24          self.entity_call(self.cw_rset.get_entity(row, col), **kwargs)