[web] Use the new '/ajax' URL path to access the AjaxController (closes #2758254) stable
authorRémi Cardona <remi.cardona@logilab.fr>
Tue, 19 Mar 2013 12:24:40 +0100
branchstable
changeset 8728 75be9de9d68e
parent 8726 e08ab56ea2ac
child 8729 ea3fc8e1edee
[web] Use the new '/ajax' URL path to access the AjaxController (closes #2758254) 5a81fa526b30 took care of all the JS code, this patch cleans up the remaining python bits.
web/component.py
web/formwidgets.py
web/request.py
web/test/unittest_web.py
web/views/tabs.py
web/views/treeview.py
--- a/web/component.py	Tue Mar 12 19:24:43 2013 +0100
+++ b/web/component.py	Tue Mar 19 12:24:40 2013 +0100
@@ -123,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', %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 12 19:24:43 2013 +0100
+++ b/web/formwidgets.py	Tue Mar 19 12:24:40 2013 +0100
@@ -842,7 +842,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 12 19:24:43 2013 +0100
+++ b/web/request.py	Tue Mar 19 12:24:40 2013 +0100
@@ -714,7 +714,7 @@
         # 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)
+        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 12 19:24:43 2013 +0100
+++ b/web/test/unittest_web.py	Tue Mar 19 12:24:40 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 12 19:24:43 2013 +0100
+++ b/web/views/tabs.py	Tue Mar 19 12:24:40 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 12 19:24:43 2013 +0100
+++ b/web/views/treeview.py	Tue Mar 19 12:24:40 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',