# HG changeset patch # User Aurelien Campeas # Date 1402579321 -7200 # Node ID 96085e37906612a30b53f8af8622e561a0e2885d # Parent 88f60d4b9952e3321c5ce2df26b5440fe3ca76b7 [views,js] remove user_callback feature Related to #3975260. diff -r 88f60d4b9952 -r 96085e379066 doc/3.21.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/3.21.rst Thu Jun 12 15:22:01 2014 +0200 @@ -0,0 +1,9 @@ +What's new in CubicWeb 3.21? +============================ + + +Deprecated code drops +--------------------- + +* the user_callback api has been removed; people should use plain + ajax functions instead diff -r 88f60d4b9952 -r 96085e379066 web/data/cubicweb.ajax.js --- a/web/data/cubicweb.ajax.js Fri Feb 06 14:43:40 2015 +0100 +++ b/web/data/cubicweb.ajax.js Thu Jun 12 15:22:01 2014 +0200 @@ -517,59 +517,6 @@ }); } -userCallback = cw.utils.deprecatedFunction( - '[3.19] use a plain ajaxfunc instead of user callbacks', - function userCallback(cbname) { - setProgressCursor(); - var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('user_callback', null, cbname)); - d.addCallback(resetCursor); - d.addErrback(resetCursor); - d.addErrback(remoteCallFailed); - return d; -}); - -userCallbackThenUpdateUI = cw.utils.deprecatedFunction( - '[3.19] use a plain ajaxfunc instead of user callbacks', - function userCallbackThenUpdateUI(cbname, compid, rql, msg, registry, nodeid) { - var d = userCallback(cbname); - d.addCallback(function() { - $('#' + nodeid).loadxhtml(AJAX_BASE_URL, ajaxFuncArgs('render', {'rql': rql}, - registry, compid), null, 'swap'); - if (msg) { - updateMessage(msg); - } - }); -}); - -userCallbackThenReloadPage = cw.utils.deprecatedFunction( - '[3.19] use a plain ajaxfunc instead of user callbacks', - function userCallbackThenReloadPage(cbname, msg) { - var d = userCallback(cbname); - d.addCallback(function() { - window.location.reload(); - if (msg) { - updateMessage(msg); - } - }); -}); - -/** - * .. function:: unregisterUserCallback(cbname) - * - * unregisters the python function registered on the server's side - * while the page was generated. - */ -unregisterUserCallback = cw.utils.deprecatedFunction( - '[3.19] use a plain ajaxfunc instead of user callbacks', - function unregisterUserCallback(cbname) { - setProgressCursor(); - var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('unregister_user_callback', - null, cbname)); - d.addCallback(resetCursor); - d.addErrback(resetCursor); - d.addErrback(remoteCallFailed); -}); - //============= XXX move those functions? ====================================// function openHash() { diff -r 88f60d4b9952 -r 96085e379066 web/request.py --- a/web/request.py Fri Feb 06 14:43:40 2015 +0100 +++ b/web/request.py Thu Jun 12 15:22:01 2014 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. @@ -403,67 +403,6 @@ return breadcrumbs.pop() return self.base_url() - @deprecated('[3.19] use a traditional ajaxfunc / controller') - def user_rql_callback(self, rqlargs, *args, **kwargs): - """register a user callback to execute some rql query, and return a URL - to call that callback which can be inserted in an HTML view. - - `rqlargs` should be a tuple containing argument to give to the execute function. - - The first argument following rqlargs must be the message to be - displayed after the callback is called. - - For other allowed arguments, see :meth:`user_callback` method - """ - def rqlexec(req, rql, args=None, key=None): - req.execute(rql, args, key) - return self.user_callback(rqlexec, rqlargs, *args, **kwargs) - - @deprecated('[3.19] use a traditional ajaxfunc / controller') - def user_callback(self, cb, cbargs, *args, **kwargs): - """register the given user callback and return a URL which can - be inserted in an HTML view. When the URL is accessed, the - callback function will be called (as 'cb(req, \*cbargs)', and a - message will be displayed in the web interface. The third - positional argument must be 'msg', containing the message. - - You can specify the underlying js function to call using a 'jsfunc' - named args, to one of :func:`userCallback`, - ':func:`userCallbackThenUpdateUI`, ':func:`userCallbackThenReloadPage` - (the default). Take care arguments may vary according to the used - function. - """ - self.add_js('cubicweb.ajax.js') - jsfunc = kwargs.pop('jsfunc', 'userCallbackThenReloadPage') - assert not kwargs, 'dunno what to do with remaining kwargs: %s' % kwargs - cbname = self.register_onetime_callback(cb, *cbargs) - return "javascript: %s" % getattr(js, jsfunc)(cbname, *args) - - @deprecated('[3.19] use a traditional ajaxfunc / controller') - def register_onetime_callback(self, func, *args): - cbname = build_cb_uid(func.__name__) - def _cb(req): - try: - return func(req, *args) - finally: - self.unregister_callback(self.pageid, cbname) - self.set_page_data(cbname, _cb) - return cbname - - @deprecated('[3.19] use a traditional ajaxfunc / controller') - def unregister_callback(self, pageid, cbname): - assert pageid is not None - assert cbname.startswith('cb_') - self.info('unregistering callback %s for pageid %s', cbname, pageid) - self.del_page_data(cbname) - - @deprecated('[3.19] use a traditional ajaxfunc / controller') - def clear_user_callbacks(self): - if self.session is not None: # XXX - for key in list(self.session.data): - if key.startswith('cb_'): - del self.session.data[key] - # web edition helpers ##################################################### @cached # so it's writed only once diff -r 88f60d4b9952 -r 96085e379066 web/views/ajaxcontroller.py --- a/web/views/ajaxcontroller.py Fri Feb 06 14:43:40 2015 +0100 +++ b/web/views/ajaxcontroller.py Thu Jun 12 15:22:01 2014 +0200 @@ -427,26 +427,6 @@ """returns the URL of the external resource named `resource`""" return self._cw.uiprops[resource] -@ajaxfunc(output_type='json', check_pageid=True) -def user_callback(self, cbname): - """execute the previously registered user callback `cbname`. - - If matching callback is not found, return None - """ - page_data = self._cw.session.data.get(self._cw.pageid, {}) - try: - cb = page_data[cbname] - except KeyError: - self.warning('unable to find user callback %s', cbname) - return None - return cb(self._cw) - - -@ajaxfunc -def unregister_user_callback(self, cbname): - """unregister user callback `cbname`""" - self._cw.unregister_callback(self._cw.pageid, cbname) - @ajaxfunc def unload_page_data(self): """remove user's session data associated to current pageid"""