Previous topic

Fundamental Data Structures

Next topic

Service Definition

This Page

Application Definition

class spyne.application.Application(services, tns, name=None, in_protocol=None, out_protocol=None, interface=None)[source]

The Application class is the glue between one or more service definitions, input and output protocols.

Parameters:
  • services – An iterable of ServiceBase subclasses that define the exposed services.
  • tns – The targetNamespace attribute of the exposed service.
  • name – The optional name attribute of the exposed service. The default is the name of the application class which is by default ‘Application’.
  • in_protocol – A ProtocolBase instance that denotes the input protocol. It’s only optional for NullServer transport.
  • out_protocol – A ProtocolBase instance that denotes the output protocol. It’s only optional for NullServer transport.
  • interface – Ignored. Kept for backwards-compatibility purposes.
Supported 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_context_constructed:

    Called from the constructor of the MethodContext instance.

  • method_context_destroyed:

    Called from the destructor of the MethodContext instance.

call_wrapper(ctx)[source]

This method calls the call_wrapper method in the service definition. This can be overridden to make an application-wide custom exception management.

process_request(ctx)[source]

Takes a MethodContext instance. Returns the response to the request as a native python object. If the function throws an exception, it returns None and sets the exception object to ctx.out_error.

Overriding this method would break event management. So this is not meant to be overridden unless you know what you’re doing.

spyne.application.return_traceback_in_unhandled_exceptions()[source]

Call this function first thing in your main function to return tracebacks to your clients in case of unhandled exceptions.