diff -r c09feae04094 -r 268b6349baf3 web/views/ajaxcontroller.py --- a/web/views/ajaxcontroller.py Fri Aug 03 13:29:37 2012 +0200 +++ b/web/views/ajaxcontroller.py Fri Sep 07 14:01:59 2012 +0200 @@ -63,6 +63,7 @@ __docformat__ = "restructuredtext en" +from warnings import warn from functools import partial from logilab.common.date import strptime @@ -114,22 +115,20 @@ fname = self._cw.form['fname'] except KeyError: raise RemoteCallFailed('no method specified') + # 1/ check first for old-style (JSonController) ajax func for bw compat try: - func = self._cw.vreg['ajax-func'].select(fname, self._cw) - except ObjectNotFound: - # function not found in the registry, inspect JSonController for - # backward compatibility + func = getattr(basecontrollers.JSonController, 'js_%s' % fname).im_func + func = partial(func, self) + except AttributeError: + # 2/ check for new-style (AjaxController) ajax func try: - func = getattr(basecontrollers.JSonController, 'js_%s' % fname).im_func - func = partial(func, self) - except AttributeError: + func = self._cw.vreg['ajax-func'].select(fname, self._cw) + except ObjectNotFound: raise RemoteCallFailed('no %s method' % fname) - else: - self.warning('remote function %s found on JSonController, ' - 'use AjaxFunction / @ajaxfunc instead', fname) - except NoSelectableObject: - raise RemoteCallFailed('method %s not available in this context' - % fname) + else: + warn('[3.15] remote function %s found on JSonController, ' + 'use AjaxFunction / @ajaxfunc instead' % fname, + DeprecationWarning, stacklevel=2) # no attribute means the callback takes no argument args = self._cw.form.get('arg', ()) if not isinstance(args, (list, tuple)):