Package wtf :: Module services :: Class ServiceInterface
[hide private]
[frames] | no frames]

Class ServiceInterface

source code

object --+
         |
        ServiceInterface

Interface for global and local services, initialized at startup time
Instance Methods [hide private]
 
__init__(self, config, opts, args)
Initialization
source code
 
shutdown(self)
Shutdown the service
source code
tuple
global_service(self)
Return the global service object
source code
callable
middleware(self, func)
Middleware factory
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, config, opts, args)
(Constructor)

source code 
Initialization
Parameters:
  • config (wtf.config.Config) - Configuration
  • opts (optparse.OptionContainer) - Command line options
  • args (list) - Positioned command line arguments
Overrides: object.__init__

shutdown(self)

source code 

Shutdown the service

This method is called when the services are no longer needed. It can be used to release external resources etc in a clean way.

global_service(self)

source code 

Return the global service object

If there's no global service provided, the method is expected to return None

Returns: tuple
A tuple containing the global object the service provides and the name which the object will be stored under in the service module (('name', any))

middleware(self, func)

source code 
Middleware factory
Parameters:
  • func (callable) - The function to wrap (WSGI compatible callable)
Returns: callable
A WSGI callable. If the service does not provide a WSGI middleware, the func argument should just be returned, the initialized middleware (wrapping func) otherwise.