Package pyamf :: Package remoting |
[hide private]
[frames] | no frames]

# Package remoting

source code

AMF Remoting support.

A Remoting request from the client consists of a short preamble, headers, and bodies. The preamble contains basic information about the nature of the request. Headers can be used to request debugging information, send authentication info, tag transactions, etc. Bodies contain actual Remoting requests and responses. A single Remoting envelope can contain several requests; Remoting supports batching out of the box.

Client headers and bodies need not be responded to in a one-to-one manner. That is, a body or header may not require a response. Debug information is requested by a header but sent back as a body object. The response index is essential for the Adobe Flash Player to understand the response therefore.

See Also:
  Remoting Envelope on OSFlash (external), Remoting Headers on OSFlash (external), Remoting Debug Headers on OSFlash (external)

Since: 0.1.0

Submodules | [hide private]
pyamf.remoting.amf0: AMF0 Remoting support. pyamf.remoting.amf3: AMF3 RemoteObject support. pyamf.remoting.client: Remoting client implementation. pyamf.remoting.gateway: Remoting server implementations. pyamf.remoting.gateway.django: Gateway for the Django framework. pyamf.remoting.gateway.google: Gateway for Google App Engine. pyamf.remoting.gateway.twisted: Twisted server implementation. pyamf.remoting.gateway.wsgi: WSGI server implementation.

Classes | [hide private]
| RemotingError Generic remoting error class.
| RemotingCallFailed Raised if `Server.Call.Failed` received.
| HeaderCollection Collection of AMF message headers.
| Envelope I wrap an entire request, encapsulating headers and bodies.
| Message I represent a singular request/response, containing a collection of headers and one body of data.
| Request An AMF Request payload.
| Response An AMF Response.
| BaseFault I represent a `Fault` message (`mx.rpc.Fault`).
| ErrorFault I represent an error level fault.

Functions | [hide private]
`tuple` |
_read_header(stream, decoder, strict=False) Read AMF Message header. | source code
_write_header(name, header, required, stream, encoder, strict=False) Write AMF message header. | source code
`tuple` |
_read_body(stream, decoder, strict=False, logger=None) Read AMF message body. | source code
_write_body(name, message, stream, encoder, strict=False) Write AMF message body. | source code
_get_status(status) Get status code. | source code
get_fault_class(level, **kwargs) | source code
get_fault(data) | source code
Envelope |
decode(stream, context=None, strict=False, logger=None, timezone_offset=None) Decodes the incoming stream as a remoting message. | source code
`StringIO` |
encode(msg, context=None, strict=False, logger=None, timezone_offset=None) Encodes AMF stream and returns file object. | source code
get_exception_from_fault(fault) | source code

Variables | [hide private]
| STATUS_OK = `0` Succesful call.
| STATUS_ERROR = `1` Reserved for runtime errors.
| STATUS_DEBUG = `2` Debug information.
| STATUS_CODES = ``{`0`:` `'``/onResult``'``,` 1`:` `'``/onStatus``'``,` 2`:` `'``/onDebugEv``...`` List of available status response codes.
| CONTENT_TYPE = ``'``application/x-amf``'`` AMF mimetype.
| ERROR_CODES = ``{`0`:` `'``Server.Call.Failed``'``}``
| APPEND_TO_GATEWAY_URL = ``'``AppendToGatewayUrl``'``
| REPLACE_GATEWAY_URL = ``'``ReplaceGatewayUrl``'``
| REQUEST_PERSISTENT_HEADER = ``'``RequestPersistentHeader``'``
| ERROR_CALL_FAILED = `0`

Imports: pyamf, util

Function Details | [hide private]

### _read_header(stream, decoder, strict=False) | source code
Read AMF Message header. Parameters: `stream` (BufferedByteStream) - AMF data. `decoder` (amf0.Decoder) - AMF decoder instance `strict` (`bool`) - Use strict decoding policy. Default is `False`. Returns: `tuple` Name of the header. A `bool` determining if understanding this header is required. Value of the header. Raises: `DecodeError` - The data that was read from the stream does not match the header length.

### _write_header(name, header, required, stream, encoder, strict=False) | source code
Write AMF message header. Parameters: `name` (`str`) - Name of the header. `header` () - Raw header data. `required` (`bool`) - Required header. `stream` (BufferedByteStream) - AMF data. `encoder` (amf0.Encoder or amf3.Encoder) - AMF encoder instance. `strict` (`bool`) - Use strict encoding policy. Default is `False`.

### _read_body(stream, decoder, strict=False, logger=None) | source code
Read AMF message body. Parameters: `stream` (BufferedByteStream) - AMF data. `decoder` (amf0.Decoder) - AMF decoder instance. `strict` (`bool`) - Use strict decoding policy. Default is `False`. `logger` (A `logging.Logger` instance or `None`.) - Used to log interesting events whilst reading a remoting body. Returns: `tuple` A `tuple` containing: ID of the request Request or Response Raises: `DecodeError` - Data read from stream does not match body length.

### _write_body(name, message, stream, encoder, strict=False) | source code
Write AMF message body. Parameters: `name` (`basestring`) - The name of the request. `message` (Request or Response) - The AMF payload. `encoder` (amf0.Encoder) - Encoder to use. `strict` (`bool`) - Use strict encoding policy. Default is `False`. `stream` (BufferedByteStream) Raises: `TypeError` - Unknown message type for `message`.

### _get_status(status) | source code
Get status code. Parameters: `status` (`str`) Returns: Status code. Raises: `ValueError` - The status code is unknown. See Also: STATUS_CODES

### decode(stream, context=None, strict=False, logger=None, timezone_offset=None) | source code
Decodes the incoming stream as a remoting message. Parameters: `stream` (BufferedByteStream) - AMF data. `context` (amf0.Context or amf3.Context) - Context. `strict` (`bool`) - Enforce strict decoding. Default is `False`. `logger` (A `logging.Logger` instance or `None`.) - Used to log interesting events whilst decoding a remoting message. `timezone_offset` (`datetime.timedelta`) - The difference between the current timezone and UTC. Date/times should always be handled in UTC to avoid confusion but this is required for legacy systems. Returns: Envelope Message envelope. Raises: `DecodeError` - Malformed stream. `RuntimeError` - Decoder is unable to fully consume the stream buffer.

### encode(msg, context=None, strict=False, logger=None, timezone_offset=None) | source code
Encodes AMF stream and returns file object. Parameters: `msg` (Envelope) - The message to encode. `strict` (`bool`) - Determines whether encoding should be strict. Specifically header/body lengths will be written correctly, instead of the default 0. Default is `False`. Introduced in 0.4. `logger` (A `logging.Logger` instance or `None`.) - Used to log interesting events whilst encoding a remoting message. `timezone_offset` (`datetime.timedelta`) - The difference between the current timezone and UTC. Date/times should always be handled in UTC to avoid confusion but this is required for legacy systems. Returns: `StringIO` File object.

### get_exception_from_fault(fault) | source code
Raises: `RemotingError` - Default exception from fault.

Variables Details | [hide private]

  ### STATUS_CODES List of available status response codes. Value:
      {0: '/onResult', 1: '/onStatus', 2: '/onDebugEvents'}