I have a JSON RPC API as a set of methods which all have some common processing involved, esp. regarding exceptions. To catch those and in turn raise proper JsonRpcError, with proper code and message, I wanted to wrap the methods in a common decorator.
But then I get "method not found", and if I swap @common_rpc with @jsonrpc_method, of course then params are not identified by pyramid_rpc (MapplyViewMapper).
Am I doing something wrong, perhaps missing to do something with Venusian? Or is it impossible to chain decorators with @jsonrpc_method?
Thanks.
--
.oO V Oo.
Work Hard,
Increase Production,
Prevent Accidents,
and
Be Happy! ;)
You haven't shown me the signature of your decorator or any errors.
Ignoring that, jsonrpc_method, similar to view_config in pyramid,
supports a `decorator` argument that guarantees you a common signature
for decorators:
def common_rpc(view):
def _wrapped(context, request):
# do stuff with request.rpc_args or whatever else
return view(context, request)
return _wrapped
On Tue, Aug 7, 2012 at 10:42 AM, Vlad K. <v...@haronmedia.com> wrote:
> Hi all,
> I have a JSON RPC API as a set of methods which all have some common
> processing involved, esp. regarding exceptions. To catch those and in turn
> raise proper JsonRpcError, with proper code and message, I wanted to wrap
> the methods in a common decorator.
> But then I get "method not found", and if I swap @common_rpc with
> @jsonrpc_method, of course then params are not identified by pyramid_rpc
> (MapplyViewMapper).
> Am I doing something wrong, perhaps missing to do something with Venusian?
> Or is it impossible to chain decorators with @jsonrpc_method?
> Thanks.
> --
> .oO V Oo.
> Work Hard,
> Increase Production,
> Prevent Accidents,
> and
> Be Happy! ;)
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
> You haven't shown me the signature of your decorator or any errors.
> Ignoring that, jsonrpc_method, similar to view_config in pyramid,
> supports a `decorator` argument that guarantees you a common signature
> for decorators:
Ah, I missed to check the docs on config.add_view(). Yeah, the decorator argument now does what I expect of the code.
The error was simple, default pyramid_jsonrpc "method not found" which you get if you call an unregistered method, and the common_rpc() decorator is the following: