[request] memoize tabindex across ajax calls (on pageid) to avoid ui confusion stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Thu, 16 Sep 2010 11:30:14 +0200
branchstable
changeset 6259 c3d98e4bee12
parent 6258 9b5c008267b0
child 6260 e06750b556ad
[request] memoize tabindex across ajax calls (on pageid) to avoid ui confusion
web/request.py
--- a/web/request.py	Thu Sep 16 11:30:09 2010 +0200
+++ b/web/request.py	Thu Sep 16 11:30:14 2010 +0200
@@ -99,9 +99,6 @@
         # search state: 'normal' or 'linksearch' (eg searching for an object
         # to create a relation with another)
         self.search_state = ('normal',)
-        # tabindex generator
-        self.tabindexgen = count(1)
-        self.next_tabindex = self.tabindexgen.next
         # page id, set by htmlheader template
         self.pageid = None
         self._set_pageid()
@@ -131,6 +128,13 @@
         """
         return self.set_varmaker()
 
+    def _get_tabindex_func(self):
+        nextfunc = self.get_page_data('nexttabfunc')
+        if nextfunc is None:
+            nextfunc = count(1).next
+            self.set_page_data('nexttabfunc', nextfunc)
+        return nextfunc
+
     def set_varmaker(self):
         varmaker = self.get_page_data('rql_varmaker')
         if varmaker is None:
@@ -143,6 +147,8 @@
         or an anonymous connection is open
         """
         super(CubicWebRequestBase, self).set_session(session, user)
+        # tabindex generator
+        self.next_tabindex = self._get_tabindex_func()
         # set request language
         vreg = self.vreg
         if self.user: