116 try: |
115 try: |
117 fname = self._cw.form['fname'] |
116 fname = self._cw.form['fname'] |
118 except KeyError: |
117 except KeyError: |
119 raise RemoteCallFailed('no method specified', |
118 raise RemoteCallFailed('no method specified', |
120 status=http_client.BAD_REQUEST) |
119 status=http_client.BAD_REQUEST) |
121 # 1/ check first for old-style (JSonController) ajax func for bw compat |
120 try: |
122 try: |
121 func = self._cw.vreg['ajax-func'].select(fname, self._cw) |
123 func = getattr(basecontrollers.JSonController, 'js_%s' % fname) |
122 except ObjectNotFound: |
124 if PY2: |
123 raise RemoteCallFailed('no %s method' % fname, |
125 func = func.__func__ |
124 status=http_client.BAD_REQUEST) |
126 func = partial(func, self) |
|
127 except AttributeError: |
|
128 # 2/ check for new-style (AjaxController) ajax func |
|
129 try: |
|
130 func = self._cw.vreg['ajax-func'].select(fname, self._cw) |
|
131 except ObjectNotFound: |
|
132 raise RemoteCallFailed('no %s method' % fname, |
|
133 status=http_client.BAD_REQUEST) |
|
134 else: |
|
135 warn('[3.15] remote function %s found on JSonController, ' |
|
136 'use AjaxFunction / @ajaxfunc instead' % fname, |
|
137 DeprecationWarning, stacklevel=2) |
|
138 debug_mode = self._cw.vreg.config.debugmode |
125 debug_mode = self._cw.vreg.config.debugmode |
139 # no <arg> attribute means the callback takes no argument |
126 # no <arg> attribute means the callback takes no argument |
140 args = self._cw.form.get('arg', ()) |
127 args = self._cw.form.get('arg', ()) |
141 if not isinstance(args, (list, tuple)): |
128 if not isinstance(args, (list, tuple)): |
142 args = (args,) |
129 args = (args,) |