Package pyamf :: Package remoting :: Package gateway :: Class BaseGateway

[hide private]
[frames] | no frames]

# Class BaseGateway

source code

Generic Remoting gateway.

Nested Classes | [hide private]

| _request_class Remoting service request.

Instance Methods | [hide private]

__init__(self, services=`{``}`, **kwargs) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code

addService(self, service, name=None, description=None, authenticator=None, expose_request=None, preprocessor=None) Adds a service to the gateway. | source code

_get_timezone_offset(self) | source code

removeService(self, service) Removes a service from the gateway. | source code

ServiceRequest

getServiceRequest(self, request, target) Returns a service based on the message. | source code

getProcessor(self, request) Returns request processor. | source code

Envelope

getResponse(self, amf_request) Returns the response to the request. | source code

`bool`

mustExposeRequest(self, service_request) Decides whether the underlying http request should be exposed as the first argument to the method call. | source code

getAuthenticator(self, service_request) Gets an authenticator callable based on the service_request. | source code

`bool`

authenticateRequest(self, service_request, username, password, **kwargs) Processes an authentication request. | source code

getPreprocessor(self, service_request) Gets a preprocessor callable based on the service_request. | source code

preprocessRequest(self, service_request, *args, **kwargs) Preprocesses a request. | source code

callServiceRequest(self, service_request, *args, **kwargs) Executes the service_request call | source code

Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Instance Variables | [hide private]

`Callable` or `None` | authenticator A callable that will check the credentials of the request before allowing access to the service.
`bool` | debug Provides debugging information when an error occurs.
| logger A logging instance.
`Callable` or `None` | preprocessor Called before the actual service method is invoked.
ServiceCollection | services A map of service names to callables.
`bool` | strict Defines whether the gateway should use strict en/decoding.
| timezone_offset A `datetime.timedelta` between UTC and the timezone to be encoded.

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, services=`{``}`, **kwargs)
(Constructor)

source code

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
  (inherited documentation)

### addService(self, service, name=None, description=None, authenticator=None, expose_request=None, preprocessor=None)

source code

Adds a service to the gateway.

Parameters:
  - `service` (`callable`, class instance, or a module) - The service to add to the gateway.
  - `name` (`str`) - The name of the service.
Raises:
  - `pyamf.remoting.RemotingError` - Service already exists.
  - `TypeError` - `service` cannot be a scalar value.
  - `TypeError` - `service` must be `callable` or a module.

### removeService(self, service)

source code

Removes a service from the gateway.

Parameters:
  - `service` (`callable` or a class instance) - The service to remove from the gateway.
Raises:
  - `NameError` - Service not found.

### getServiceRequest(self, request, target)

source code

Returns a service based on the message.

Parameters:
  - `request` (Request) - The AMF request.
Returns: ServiceRequest
Raises:
  - `UnknownServiceError` - Unknown service.

### getProcessor(self, request)

source code

Returns request processor.

Parameters:
  - `request` (Request) - The AMF message.

### getResponse(self, amf_request)

source code

Returns the response to the request.

Any implementing gateway must define this function.

Parameters:
  - `amf_request` (Envelope) - The AMF request.
Returns: Envelope
  The AMF response.

### mustExposeRequest(self, service_request)

source code

Decides whether the underlying http request should be exposed as the first argument to the method call. This is granular, looking at the service method first, then at the service level and finally checking the gateway.

Returns: `bool`

### getAuthenticator(self, service_request)

source code

Gets an authenticator callable based on the service_request. This is granular, looking at the service method first, then at the service level and finally to see if there is a global authenticator function for the gateway. Returns `None` if one could not be found.

### authenticateRequest(self, service_request, username, password, **kwargs)

source code

Processes an authentication request. If no authenticator is supplied, then authentication succeeds.

Returns: `bool`
  Returns a `bool` based on the result of authorization. A value of `False` will stop processing the request and return an error to the client.

### getPreprocessor(self, service_request)

source code

Gets a preprocessor callable based on the service_request. This is granular, looking at the service method first, then at the service level and finally to see if there is a global preprocessor function for the gateway. Returns `None` if one could not be found.

Instance Variable Details | [hide private]

### authenticator

A callable that will check the credentials of the request before allowing access to the service. Will return a `bool` value.

Type:
  `Callable` or `None`

### debug

Provides debugging information when an error occurs. Use only in non production settings.

Type:
  `bool`

### preprocessor

Called before the actual service method is invoked. Useful for setting up sessions etc.

Type:
  `Callable` or `None`

### timezone_offset

A `datetime.timedelta` between UTC and the timezone to be encoded. Most dates should be handled as UTC to avoid confusion but for older legacy systems this is not an option. Supplying an int as this will be interpretted in seconds.