[views,js] remove user_callback feature

Related to #3975260.

authorAurelien Campeas <aurelien.campeas@logilab.fr>
changeset76fb2961684f
branchdefault
phasedraft
hiddenyes
parent revision#724240ef1ec5 [shared data] remove get/set_shared_data api
child revision#167aca862c12 Remove remote repository-access-through-pyro support
files modified by this revision
doc/3.21.rst
view.py
web/data/cubicweb.ajax.js
web/request.py
web/views/ajaxcontroller.py
web/views/ajaxedit.py
# HG changeset patch
# User Aurelien Campeas <aurelien.campeas@logilab.fr>
# Date 1402579321 -7200
# Thu Jun 12 15:22:01 2014 +0200
# Node ID 76fb2961684f21267e4b72855c2d3ba2de9854c6
# Parent 724240ef1ec504192f61c9c3e1fffa971c4988f7
[views,js] remove user_callback feature

Related to #3975260.

diff --git a/doc/3.21.rst b/doc/3.21.rst
@@ -6,6 +6,7 @@
1  ---------------------
2 
3  * the get/set_shared_data api has been removed; people should use
4    transaction_data or session_data instead
5 
6 -
7 +* the user_callback api has been removed; people should use plain
8 +  ajax functions instead
diff --git a/view.py b/view.py
@@ -1,6 +1,6 @@
9 -# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
10 +# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
11  # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
12  #
13  # This file is part of CubicWeb.
14  #
15  # CubicWeb is free software: you can redistribute it and/or modify it under the
diff --git a/web/data/cubicweb.ajax.js b/web/data/cubicweb.ajax.js
@@ -515,63 +515,10 @@
16          document.location.hash = '#header';
17          updateMessage(_("bookmark has been removed"));
18      });
19  }
20 
21 -userCallback = cw.utils.deprecatedFunction(
22 -    '[3.19] use a plain ajaxfunc instead of user callbacks',
23 -    function userCallback(cbname) {
24 -    setProgressCursor();
25 -    var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('user_callback', null, cbname));
26 -    d.addCallback(resetCursor);
27 -    d.addErrback(resetCursor);
28 -    d.addErrback(remoteCallFailed);
29 -    return d;
30 -});
31 -
32 -userCallbackThenUpdateUI = cw.utils.deprecatedFunction(
33 -    '[3.19] use a plain ajaxfunc instead of user callbacks',
34 -    function userCallbackThenUpdateUI(cbname, compid, rql, msg, registry, nodeid) {
35 -    var d = userCallback(cbname);
36 -    d.addCallback(function() {
37 -        $('#' + nodeid).loadxhtml(AJAX_BASE_URL, ajaxFuncArgs('render', {'rql': rql},
38 -                                                       registry, compid), null, 'swap');
39 -        if (msg) {
40 -            updateMessage(msg);
41 -        }
42 -    });
43 -});
44 -
45 -userCallbackThenReloadPage = cw.utils.deprecatedFunction(
46 -    '[3.19] use a plain ajaxfunc instead of user callbacks',
47 -    function userCallbackThenReloadPage(cbname, msg) {
48 -    var d = userCallback(cbname);
49 -    d.addCallback(function() {
50 -        window.location.reload();
51 -        if (msg) {
52 -            updateMessage(msg);
53 -        }
54 -    });
55 -});
56 -
57 -/**
58 - * .. function:: unregisterUserCallback(cbname)
59 - *
60 - * unregisters the python function registered on the server's side
61 - * while the page was generated.
62 - */
63 -unregisterUserCallback = cw.utils.deprecatedFunction(
64 -    '[3.19] use a plain ajaxfunc instead of user callbacks',
65 -    function unregisterUserCallback(cbname) {
66 -    setProgressCursor();
67 -    var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs('unregister_user_callback',
68 -                                            null, cbname));
69 -    d.addCallback(resetCursor);
70 -    d.addErrback(resetCursor);
71 -    d.addErrback(remoteCallFailed);
72 -});
73 -
74 
75  //============= XXX move those functions? ====================================//
76  function openHash() {
77      if (document.location.hash) {
78          var nid = document.location.hash.replace('#', '');
diff --git a/web/request.py b/web/request.py
@@ -1,6 +1,6 @@
79 -# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
80 +# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
81  # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
82  #
83  # This file is part of CubicWeb.
84  #
85  # CubicWeb is free software: you can redistribute it and/or modify it under the
@@ -401,71 +401,10 @@
86          breadcrumbs = self.session.data.get('breadcrumbs')
87          if breadcrumbs:
88              return breadcrumbs.pop()
89          return self.base_url()
90 
91 -    @deprecated('[3.19] use a traditional ajaxfunc / controller')
92 -    def user_rql_callback(self, rqlargs, *args, **kwargs):
93 -        """register a user callback to execute some rql query, and return a URL
94 -        to call that callback which can be inserted in an HTML view.
95 -
96 -        `rqlargs` should be a tuple containing argument to give to the execute function.
97 -
98 -        The first argument following rqlargs must be the message to be
99 -        displayed after the callback is called.
100 -
101 -        For other allowed arguments, see :meth:`user_callback` method
102 -        """
103 -        def rqlexec(req, rql, args=None, key=None):
104 -            req.execute(rql, args, key)
105 -        return self.user_callback(rqlexec, rqlargs, *args, **kwargs)
106 -
107 -    @deprecated('[3.19] use a traditional ajaxfunc / controller')
108 -    def user_callback(self, cb, cbargs, *args, **kwargs):
109 -        """register the given user callback and return a URL which can
110 -        be inserted in an HTML view. When the URL is accessed, the
111 -        callback function will be called (as 'cb(req, \*cbargs)', and a
112 -        message will be displayed in the web interface. The third
113 -        positional argument must be 'msg', containing the message.
114 -
115 -        You can specify the underlying js function to call using a 'jsfunc'
116 -        named args, to one of :func:`userCallback`,
117 -        ':func:`userCallbackThenUpdateUI`, ':func:`userCallbackThenReloadPage`
118 -        (the default). Take care arguments may vary according to the used
119 -        function.
120 -        """
121 -        self.add_js('cubicweb.ajax.js')
122 -        jsfunc = kwargs.pop('jsfunc', 'userCallbackThenReloadPage')
123 -        assert not kwargs, 'dunno what to do with remaining kwargs: %s' % kwargs
124 -        cbname = self.register_onetime_callback(cb, *cbargs)
125 -        return "javascript: %s" % getattr(js, jsfunc)(cbname, *args)
126 -
127 -    @deprecated('[3.19] use a traditional ajaxfunc / controller')
128 -    def register_onetime_callback(self, func, *args):
129 -        cbname = build_cb_uid(func.__name__)
130 -        def _cb(req):
131 -            try:
132 -                return func(req, *args)
133 -            finally:
134 -                self.unregister_callback(self.pageid, cbname)
135 -        self.set_page_data(cbname, _cb)
136 -        return cbname
137 -
138 -    @deprecated('[3.19] use a traditional ajaxfunc / controller')
139 -    def unregister_callback(self, pageid, cbname):
140 -        assert pageid is not None
141 -        assert cbname.startswith('cb_')
142 -        self.info('unregistering callback %s for pageid %s', cbname, pageid)
143 -        self.del_page_data(cbname)
144 -
145 -    @deprecated('[3.19] use a traditional ajaxfunc / controller')
146 -    def clear_user_callbacks(self):
147 -        if self.session is not None: # XXX
148 -            for key in list(self.session.data):
149 -                if key.startswith('cb_'):
150 -                    del self.session.data[key]
151 -
152      # web edition helpers #####################################################
153 
154      @cached # so it's writed only once
155      def fckeditor_config(self):
156          fckeditor_url = self.build_url('fckeditor/fckeditor.js')
diff --git a/web/views/ajaxcontroller.py b/web/views/ajaxcontroller.py
@@ -425,30 +425,10 @@
157  @ajaxfunc(output_type='json')
158  def external_resource(self, resource):
159      """returns the URL of the external resource named `resource`"""
160      return self._cw.uiprops[resource]
161 
162 -@ajaxfunc(output_type='json', check_pageid=True)
163 -def user_callback(self, cbname):
164 -    """execute the previously registered user callback `cbname`.
165 -
166 -    If matching callback is not found, return None
167 -    """
168 -    page_data = self._cw.session.data.get(self._cw.pageid, {})
169 -    try:
170 -        cb = page_data[cbname]
171 -    except KeyError:
172 -        self.warning('unable to find user callback %s', cbname)
173 -        return None
174 -    return cb(self._cw)
175 -
176 -
177 -@ajaxfunc
178 -def unregister_user_callback(self, cbname):
179 -    """unregister user callback `cbname`"""
180 -    self._cw.unregister_callback(self._cw.pageid, cbname)
181 -
182  @ajaxfunc
183  def unload_page_data(self):
184      """remove user's session data associated to current pageid"""
185      self._cw.session.data.pop(self._cw.pageid, None)
186 
diff --git a/web/views/ajaxedit.py b/web/views/ajaxedit.py
@@ -1,6 +1,6 @@
187 -# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
188 +# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
189  # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
190  #
191  # This file is part of CubicWeb.
192  #
193  # CubicWeb is free software: you can redistribute it and/or modify it under the