Previous topic

Service Definition

Next topic

Common Exceptions

This Page

RPC Decorators

The spyne.decorator module contains the the @srpc decorator and its helper methods. The @srpc decorator is responsible for tagging methods as remote procedure calls extracting method’s input and output types.

It’s possible to create custom decorators that wrap the @srpc decorator in order to have a more elegant way of passing frequently-used parameter values. The @rpc decorator is a simple example of this.

spyne.decorator.rpc(*params, **kparams)[source]

Method decorator to tag a method as a remote procedure call. See spyne.decorator.srpc() for detailed information.

This decorator enables passing spyne.MethodContext instance as an implicit first argument to the user callable.

spyne.decorator.srpc(*params, **kparams)[source]

Method decorator to tag a method as a remote procedure call.

The methods tagged with this decorator do not behave like a normal python method but return ‘MethodDescriptor’ object when called.

The initial “s” stands for “static”. In Spyne’s context, that means no implicit first argument is passed to the user callable.

You should use the spyne.server.null.NullServer transport if you want to call the methods directly. You can also use the ‘function’ attribute of the returned object to call the function itself.

Parameters:
  • _in_header – A type or an iterable of types that that this method accepts as incoming header.
  • _out_header – A type or an iterable of types that that this method sends as outgoing header.
  • _in_message_name – The public name of the function.
  • _in_variable_names – The public names of the function arguments. It’s a dict that maps argument names in the code to public ones.
  • _out_variable_name – The public name of the function response object. It’s a string. Ignored when _body_style != 'wrapped' or _returns is a sequence.
  • _out_variable_names – The public name of the function response object. It’s a sequence of strings. Ignored when _body_style != 'wrapped' or or _returns is not a sequence. Must be the same length as _returns.
  • _body_style – One of ('bare', 'wrapped'). Default: 'wrapped'. In wrapped mode, wraps response objects in an additional class.
  • _soap_body_style – One of (‘rpc’, ‘document’). Default 'document'. _soap_body_style='document' is an alias for _body_style='wrapped'. _soap_body_style='rpc' is an alias for _body_style='bare'.
  • _port_type – Soap port type string.
  • _no_ctx – Don’t pass implicit ctx object to the user method.
  • _udp – Short for UserDefinedProperties, you can use this to mark the method with arbitrary metadata.
  • _aux – The auxiliary backend to run this method. None if primary.
  • _throws – A sequence of exceptions that this function can throw. No real functionality besides publishing this information in interface documents.