Previous topic

Application Definition

Next topic

RPC Decorators

This Page

Service Definition

This module contains the ServiceBase class and its helper objects.

class spyne.service.ServiceBase[source]

The ServiceBase class is the base class for all service definitions.

The convention is to have public methods defined under a subclass of this class along with common properties of public methods like header classes or auxiliary processors. The spyne.decorator.srpc() decorator or its wrappers should be used to flag public methods.

It is a natural abstract base class, because it’s of no use without any method definitions, hence the ‘Base’ suffix in the name.

This class supports the following events:
  • method_call

    Called right before the service method is executed

  • method_return_object

    Called right after the service method is executed

  • method_exception_object

    Called when an exception occurred in a service method, before the exception is serialized.

  • method_accept_document

    Called by the transport right after the incoming stream is parsed to the incoming protocol’s document type.

  • method_return_document

    Called by the transport right after the outgoing object is serialized to the outgoing protocol’s document type.

  • method_exception_document

    Called by the transport right before the outgoing exception object is serialized to the outgoing protocol’s document type.

  • method_return_string

    Called by the transport right before passing the return string to the client.

  • method_exception_string

    Called by the transport right before passing the exception string to the client.

classmethod call_wrapper(ctx)[source]

Called in place of the original method call. You can override this to do your own exception handling.

Parameters:ctx – The method context.

The overriding function must call this function by convention.

class spyne.service.ServiceBaseMeta(cls_name, cls_bases, cls_dict)[source]

Creates the spyne.MethodDescriptor objects by iterating over tagged methods.

mro() → list

return a type’s method resolution order