[web/request] clearly mark user_callback-related methods as deprecated

The deprecated decorator not only emits a warning at run-time but above all makes the deprecation immediately apparent in the source.

closes #3567793.

authorAurelien Campeas <aurelien.campeas@logilab.fr>
changeset954765f57fb6
branchdefault
phasepublic
hiddenno
parent revision#516a44ae2cc9 [book] document __unique_together__, remove bad RQLUniqueConstraint example
child revision#200bd6a601dc [warnings] put an end to warnings in the sqlite driver over `str` being sent instead of unicode strings
files modified by this revision
web/request.py
# HG changeset patch
# User Aurelien Campeas <aurelien.campeas@logilab.fr>
# Date 1400072731 -7200
# Wed May 14 15:05:31 2014 +0200
# Node ID 954765f57fb6cf48cab69f4f84194e35fec94ae1
# Parent 516a44ae2cc9ab22d8809ff2d2309f7c038fae58
[web/request] clearly mark user_callback-related methods as deprecated

The deprecated decorator not only emits a warning at run-time
but above all makes the deprecation immediately apparent in the source.

closes #3567793.

diff --git a/web/request.py b/web/request.py
@@ -401,10 +401,11 @@
1          breadcrumbs = self.session.data.get('breadcrumbs')
2          if breadcrumbs:
3              return breadcrumbs.pop()
4          return self.base_url()
5 
6 +    @deprecated('[3.19] use a traditional ajaxfunc / controller')
7      def user_rql_callback(self, rqlargs, *args, **kwargs):
8          """register a user callback to execute some rql query, and return a URL
9          to call that callback which can be inserted in an HTML view.
10 
11          `rqlargs` should be a tuple containing argument to give to the execute function.
@@ -436,26 +437,29 @@
12          jsfunc = kwargs.pop('jsfunc', 'userCallbackThenReloadPage')
13          assert not kwargs, 'dunno what to do with remaining kwargs: %s' % kwargs
14          cbname = self.register_onetime_callback(cb, *cbargs)
15          return "javascript: %s" % getattr(js, jsfunc)(cbname, *args)
16 
17 +    @deprecated('[3.19] use a traditional ajaxfunc / controller')
18      def register_onetime_callback(self, func, *args):
19          cbname = build_cb_uid(func.__name__)
20          def _cb(req):
21              try:
22                  return func(req, *args)
23              finally:
24                  self.unregister_callback(self.pageid, cbname)
25          self.set_page_data(cbname, _cb)
26          return cbname
27 
28 +    @deprecated('[3.19] use a traditional ajaxfunc / controller')
29      def unregister_callback(self, pageid, cbname):
30          assert pageid is not None
31          assert cbname.startswith('cb_')
32          self.info('unregistering callback %s for pageid %s', cbname, pageid)
33          self.del_page_data(cbname)
34 
35 +    @deprecated('[3.19] use a traditional ajaxfunc / controller')
36      def clear_user_callbacks(self):
37          if self.session is not None: # XXX
38              for key in list(self.session.data):
39                  if key.startswith('cb_'):
40                      del self.session.data[key]