[merge] backport stable fixes
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 19 Mar 2013 12:25:18 +0100
changeset 8732 0d9c8f5eb285
parent 8727 5bca35901e9b (current diff)
parent 8731 93c0c31875ac (diff)
child 8733 bdc50659f648
[merge] backport stable fixes
web/component.py
web/formwidgets.py
web/request.py
--- a/sobjects/test/unittest_supervising.py	Tue Mar 19 10:08:20 2013 +0100
+++ b/sobjects/test/unittest_supervising.py	Tue Mar 19 12:25:18 2013 +0100
@@ -72,7 +72,7 @@
 
 * added relation bookmarked_by from bookmark #EID to cwuser #EID
 
-* updated comment #EID (#EID)
+* updated comment #EID (duh?)
   http://testing.fr/cubicweb/comment/EID
 
 * deleted relation comments from comment #EID to card #EID''',
--- a/web/component.py	Tue Mar 19 10:08:20 2013 +0100
+++ b/web/component.py	Tue Mar 19 12:25:18 2013 +0100
@@ -108,7 +108,9 @@
         view = self.cw_extra_kwargs.get('view')
         if view is not None and hasattr(view, 'page_navigation_url'):
             url = view.page_navigation_url(self, path, params)
-        elif path == 'json':
+        elif path in ('json', 'ajax'):
+            # 'ajax' is the new correct controller, but the old 'json'
+            # controller should still be supported
             url = self.ajax_page_url(**params)
         else:
             url = self._cw.build_url(path, **params)
@@ -121,7 +123,7 @@
     def ajax_page_url(self, **params):
         divid = params.setdefault('divid', 'pageContent')
         params['rql'] = self.cw_rset.printable_rql()
-        return js_href("$(%s).loadxhtml('json', %s, 'get', 'swap')" % (
+        return js_href("$(%s).loadxhtml(AJAX_PREFIX_URL, %s, 'get', 'swap')" % (
             json_dumps('#'+divid), js.ajaxFuncArgs('view', params)))
 
     def page_link(self, path, params, start, stop, content):
--- a/web/formwidgets.py	Tue Mar 19 10:08:20 2013 +0100
+++ b/web/formwidgets.py	Tue Mar 19 12:25:18 2013 +0100
@@ -843,7 +843,7 @@
 
     def _get_url(self, entity, field):
         fname = self.autocomplete_initfunc
-        return entity._cw.build_url('json', fname=fname, mode='remote',
+        return entity._cw.build_url('ajax', fname=fname, mode='remote',
                                     pageid=entity._cw.pageid)
 
 
--- a/web/request.py	Tue Mar 19 10:08:20 2013 +0100
+++ b/web/request.py	Tue Mar 19 12:25:18 2013 +0100
@@ -704,7 +704,10 @@
         # after having url unescaping the content. This may make appear some
         # quote or other special characters that will break the js expression.
         extraparams.setdefault('fname', 'view')
-        url = self.build_url('json', **extraparams)
+        # remove pageid from the generated URL as it's forced as a parameter
+        # to the loadxhtml call below.
+        extraparams.pop('pageid', None)
+        url = self.build_url('ajax', **extraparams)
         cbname = build_cb_uid(url[:50])
         # think to propagate pageid. XXX see https://www.cubicweb.org/ticket/1753121
         jscode = u'function %s() { $("#%s").%s; }' % (
--- a/web/test/unittest_web.py	Tue Mar 19 10:08:20 2013 +0100
+++ b/web/test/unittest_web.py	Tue Mar 19 12:25:18 2013 +0100
@@ -38,7 +38,9 @@
         self.assertTrue(url.endswith('()'))
         cbname = url.split()[1][:-2]
         self.assertMultiLineEqual(
-            'function %s() { $("#foo").loadxhtml("http://testing.fr/cubicweb/json?%s",{"pageid": "%s"},"get","replace"); }' % (cbname, qs, req.pageid),
+            'function %s() { $("#foo").loadxhtml("http://testing.fr/cubicweb/ajax?%s",'
+            '{"pageid": "%s"},"get","replace"); }' %
+            (cbname, qs, req.pageid),
             req.html_headers.post_inlined_scripts[0])
 
 if __name__ == '__main__':
--- a/web/views/tabs.py	Tue Mar 19 10:08:20 2013 +0100
+++ b/web/views/tabs.py	Tue Mar 19 12:25:18 2013 +0100
@@ -66,7 +66,7 @@
         if tabid is None:
             tabid = uilib.domid(vid)
         w(u'<div id="lazy-%s" cubicweb:loadurl="%s">' % (
-            tabid, xml_escape(self._cw.build_url('json', **urlparams))))
+            tabid, xml_escape(self._cw.build_url('ajax', **urlparams))))
         if show_spinbox:
             # Don't use ``alt`` since image is a *visual* helper for ajax
             w(u'<img style="display: none" src="%s" alt="" id="%s-hole"/>'
--- a/web/views/treeview.py	Tue Mar 19 10:08:20 2013 +0100
+++ b/web/views/treeview.py	Tue Mar 19 12:25:18 2013 +0100
@@ -239,7 +239,7 @@
             w(u'<li class="%s">' % u' '.join(liclasses))
         else:
             rql = itree.children_rql() % {'x': entity.eid}
-            url = xml_escape(self._cw.build_url('json', rql=rql, vid=parentvid,
+            url = xml_escape(self._cw.build_url('ajax', rql=rql, vid=parentvid,
                                                 pageid=self._cw.pageid,
                                                 treeid=treeid,
                                                 fname='view',