# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1239890544 -7200 # Node ID 6042f1b342bb1b3d0c3f92461fa2121306a08a9c # Parent 6c6dbc0df829f9ce0c369f5ade580e9eadc37aeb consider kwargs in possible_actions diff -r 6c6dbc0df829 -r 6042f1b342bb cwvreg.py --- a/cwvreg.py Thu Apr 16 15:35:36 2009 +0200 +++ b/cwvreg.py Thu Apr 16 16:02:24 2009 +0200 @@ -179,9 +179,9 @@ def possible_actions(self, req, rset, **kwargs): if rset is None: - actions = self.possible_vobjects('actions', req, rset) + actions = self.possible_vobjects('actions', req, rset, **kwargs) else: - actions = rset.possible_actions() # cached implementation + actions = rset.possible_actions(**kwargs) # cached implementation result = {} for action in actions: result.setdefault(action.category, []).append(action) diff -r 6c6dbc0df829 -r 6042f1b342bb rset.py --- a/rset.py Thu Apr 16 15:35:36 2009 +0200 +++ b/rset.py Thu Apr 16 16:02:24 2009 +0200 @@ -51,7 +51,9 @@ # set by the cursor which returned this resultset self.vreg = None self.req = None - + # actions cache + self._rsetactions = None + def __str__(self): if not self.rows: return '' % self.rql @@ -70,9 +72,19 @@ '\n'.join('%s (%s)' % (r, d) for r, d in zip(rows, self.description))) - @cached - def possible_actions(self): - return self.vreg.possible_vobjects('actions', self.req, self) + def possible_actions(self, **kwargs): + if self._rsetactions is None: + self._rsetactions = {} + if kwargs: + key = tuple(sorted(kwargs.iteritems())) + else: + key = None + try: + return self._rsetactions[key] + except KeyError: + actions = self.vreg.possible_vobjects('actions', self.req, self, **kwargs) + self._rsetactions[key] = actions + return actions def __len__(self): """returns the result set's size"""