Pylons / pyramid_rpc

RPC plugins for pyramid. XML-RPC, JSON-RPC, etc.
https://docs.pylonsproject.org/projects/pyramid-rpc/en/latest/
Other
27 stars 20 forks source link

Cannot handle *args, **kwargs decorators #48

Open dstufft opened 6 years ago

dstufft commented 6 years ago

When attempting to wrap the view functions in a normal Python decorator (e.g. not a pyramid style decorator) that utilizes the *args, **kwargs pattern, pyramid_rpc breaks due to the inability to determine the number of arguments. This is true even if the decorator is using functools.wraps, which on Python 3 is smart enough to keep the function signature the same.

From digging into this, it appears this is because pyramid_rpc pokes at the code object directly instead of using a smarter helper function.

The context for this is wanting to use the @typechecked decorator from typeguard so that parameters passed from the client are type checked and generate an XMLRPC level error, instead of raising an unhandled exception (which typically get logged into something like Sentry).

However, attempting to use that results in an exception: ViewMapperArgsInvalid('too many arguments').