web/views/ajaxcontroller.py
changeset 8695 358d8bed9626
parent 8535 268b6349baf3
child 8974 c8520188eb4b
equal deleted inserted replaced
8694:d901c36bcfce 8695:358d8bed9626
   133         args = self._cw.form.get('arg', ())
   133         args = self._cw.form.get('arg', ())
   134         if not isinstance(args, (list, tuple)):
   134         if not isinstance(args, (list, tuple)):
   135             args = (args,)
   135             args = (args,)
   136         try:
   136         try:
   137             args = [json.loads(arg) for arg in args]
   137             args = [json.loads(arg) for arg in args]
   138         except ValueError, exc:
   138         except ValueError as exc:
   139             self.exception('error while decoding json arguments for '
   139             self.exception('error while decoding json arguments for '
   140                            'js_%s: %s (err: %s)', fname, args, exc)
   140                            'js_%s: %s (err: %s)', fname, args, exc)
   141             raise RemoteCallFailed(exc_message(exc, self._cw.encoding))
   141             raise RemoteCallFailed(exc_message(exc, self._cw.encoding))
   142         try:
   142         try:
   143             result = func(*args)
   143             result = func(*args)
   144         except (RemoteCallFailed, DirectResponse):
   144         except (RemoteCallFailed, DirectResponse):
   145             raise
   145             raise
   146         except Exception, exc:
   146         except Exception as exc:
   147             self.exception('an exception occurred while calling js_%s(%s): %s',
   147             self.exception('an exception occurred while calling js_%s(%s): %s',
   148                            fname, args, exc)
   148                            fname, args, exc)
   149             raise RemoteCallFailed(exc_message(exc, self._cw.encoding))
   149             raise RemoteCallFailed(exc_message(exc, self._cw.encoding))
   150         if result is None:
   150         if result is None:
   151             return ''
   151             return ''
   212             rql = rql[4:]
   212             rql = rql[4:]
   213         if rocheck:
   213         if rocheck:
   214             self._cw.ensure_ro_rql(rql)
   214             self._cw.ensure_ro_rql(rql)
   215         try:
   215         try:
   216             return self._cw.execute(rql, args)
   216             return self._cw.execute(rql, args)
   217         except Exception, ex:
   217         except Exception as ex:
   218             self.exception("error in _exec(rql=%s): %s", rql, ex)
   218             self.exception("error in _exec(rql=%s): %s", rql, ex)
   219             return None
   219             return None
   220         return None
   220         return None
   221 
   221 
   222     def _call_view(self, view, paginate=False, **kwargs):
   222     def _call_view(self, view, paginate=False, **kwargs):