This module defines classes encapsulating service descriptions. A service defines how an established client request should be handled. When a connection is accepted (usually by a listener, see the Listener module), the service bound to the given Listener is requested the create an instance of itself (using the startInstance() method, see below), which will handle the connection and takes care about proxying traffic between the client and the server.
Services are uniquely identified by their name, this name is then used as a reference to bind services to listeners. This name resolution is done through the mapping named "services" below. As a new service instance is created, it's name is registered in this hash.
The abstract interface a Service object is required to support is defined in AbstractService, customized service classes can be derived from this base class.
from Session import StackedSession
Module defining session related classes and functions.
from Stream import Stream
Module exporting an interface to the Zorp.Stream component.
from Zorp import ServiceException, LimitException
Module defining global constants, and interface entry points to the Zorp core.
This is an abstract class defining the interface Zorp uses, and as such it doesn't really do anything other than raising NotImplementedError exceptions in its methods. You should either derive a descendant from AbstractService, or use Service instead.
Table 4-95. Attributes for class AbstractService
name | The name of the service |
instance_id | the session serviced by the service |
Initialize an AbstractService or a derived class instance.
__init__ ( self, name ) |
Sets attributes based on arguments, and registers this Service to the "services" hash so that Listeners may resolve service names to service instances.
Table 4-96. Arguments for AbstractService.__init__()
self | this instance |
name | The name of the service |
ServiceException
Function to represent this object as a string
__str__ ( self ) |
This function is called by the Python core when this object is used as-, or casted to a string. It simply returns the service name.
Table 4-97. Arguments for AbstractService.__str__()
self | this instance |
Function to start an instance of this service.
startInstance ( self, session ) |
Abstract method to be implemented in derived classes. Should start an instance of the given service. A service instance takes care of the client connection, connects to the server and supervises the traffic going in either direction.
Tasks of a service instance are implemented by classes derived from Proxy.
This method unconditionally raises a NotImplementedError exception to indicate that it must be overridden by descendant classes like Service.
Table 4-98. Arguments for AbstractService.startInstance()
self | this instance |
session | start service within this session |
NotImplementedError
Function called when an instance of this service is ended
stopInstance ( self, session ) |
This function is called by Session.__del__ and indicates that a given session (instance) of this service is ended.
Table 4-99. Arguments for AbstractService.stopInstance()
self | this instance |
session | ending session |
NotImplementedError
This service class uses the standard Zorp provided Proxy class to implement the tasks required by a Service instance.
Table 4-100. Attributes for class Service
chainer | The chainer class used for the service |
proxy_class | The proxy class used for the service |
auth | Authentication handling class (None if no authentication) |
Initializes a Service instance.
__init__ ( self, name, chainer, proxy_class, auth=None, max_instances=0, ) |
This function takes its arguments, and initializes appropriate attributes in self.
Table 4-101. Arguments for Service.__init__()
self | this instance |
name | Name of this service (used in access control) |
chainer | The chainer class used for the service |
proxy_class-- The proxy class used for the service
Table 4-102. Arguments for Service.__init__()
auth | Authentication handling class (None if no authentication) |
Start a service instance.
startInstance ( self, session ) |
Called by the Listener to create an instance of this service.
Table 4-103. Arguments for Service.startInstance()
self | this instance |
session | The session object |
LimitException