rset.py
branchtls-sprint
changeset 1477 b056a49c16dc
parent 1398 5fe84a5f7035
parent 1381 6042f1b342bb
child 1802 d628defebc17
--- a/rset.py	Fri Apr 24 16:48:38 2009 +0200
+++ b/rset.py	Fri Apr 24 17:04:14 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 '<empty resultset %s>' % 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"""