fix regretion introduced by changeset "pagination/ ajaxes fixes" (2f5ebeb7665d) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 15 Sep 2010 17:20:56 +0200
branchstable
changeset 6249 1729f53b3e42
parent 6248 3f89bf00e8ce
child 6250 76c32e4a9b0f
fix regretion introduced by changeset "pagination/ ajaxes fixes" (2f5ebeb7665d) * should not paginate unless explicitly asked or if explicitly given divid == 'pageContent' * fix ajax page navigation for table view by calling component's ajax_page_url, which specify correctly divid
web/views/basecontrollers.py
web/views/tableview.py
--- a/web/views/basecontrollers.py	Wed Sep 15 17:17:51 2010 +0200
+++ b/web/views/basecontrollers.py	Wed Sep 15 17:20:56 2010 +0200
@@ -346,28 +346,29 @@
         return None
 
     def _call_view(self, view, paginate=False, **kwargs):
-        divid = self._cw.form.get('divid', 'pageContent')
-        # we need to call pagination before with the stream set
+        # set stream first, in case we need to call pagination
         stream = view.set_stream()
+        divid = self._cw.form.get('divid')
+        if divid == 'pageContent':
+            # ensure divid isn't reused by the view (e.g. table view)
+            del self._cw.form['divid']
+            # mimick main template behaviour
+            stream.write(u'<div id="pageContent">')
+            vtitle = self._cw.form.get('vtitle')
+            if vtitle:
+                stream.write(u'<h1 class="vtitle">%s</h1>\n' % vtitle)
+            paginate = True
         if paginate:
-            if divid == 'pageContent':
-                # ensure divid isn't reused by the view (e.g. table view)
-                self._cw.form.pop('divid', None)
-                # mimick main template behaviour
-                stream.write(u'<div id="pageContent">')
-                vtitle = self._cw.form.get('vtitle')
-                if vtitle:
-                    stream.write(u'<h1 class="vtitle">%s</h1>\n' % vtitle)
             view.paginate()
-            if divid == 'pageContent':
-                stream.write(u'<div id="contentmain">')
+        if divid == 'pageContent':
+            stream.write(u'<div id="contentmain">')
         view.render(**kwargs)
         extresources = self._cw.html_headers.getvalue(skiphead=True)
         if extresources:
             stream.write(u'<div class="ajaxHtmlHead">\n') # XXX use a widget ?
             stream.write(extresources)
             stream.write(u'</div>\n')
-        if paginate and divid == 'pageContent':
+        if divid == 'pageContent':
             stream.write(u'</div></div>')
         return stream.getvalue()
 
@@ -389,7 +390,7 @@
             vid = req.form.get('fallbackvid', 'noresult')
             view = self._cw.vreg['views'].select(vid, req, rset=rset)
         self.validate_cache(view)
-        return self._call_view(view, paginate=req.form.pop('paginate', True))
+        return self._call_view(view, paginate=req.form.pop('paginate', False))
 
     @xhtmlize
     def js_prop_widget(self, propkey, varname, tabindex=None):
--- a/web/views/tableview.py	Wed Sep 15 17:17:51 2010 +0200
+++ b/web/views/tableview.py	Wed Sep 15 17:20:56 2010 +0200
@@ -187,14 +187,9 @@
 
     def page_navigation_url(self, navcomp, path, params):
         if hasattr(self, 'divid'):
-            divid = self.divid
-        else:
-            divid = params.get('divid', 'pageContent'),
-        rql = params.pop('rql', self.cw_rset.printable_rql())
-        # latest 'true' used for 'swap' mode
-        return 'javascript: replacePageChunk(%s, %s, %s, %s, true)' % (
-            json_dumps(divid), json_dumps(rql), json_dumps(self.__regid__),
-            json_dumps(params))
+            params['divid'] = self.divid
+        params['vid'] = self.__regid__
+        return navcomp.ajax_page_url(**params)
 
     def show_hide_actions(self, divid, currentlydisplayed=False):
         showhide = u';'.join(toggle_action('%s%s' % (divid, what))[11:]