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, Remoting Headers on OSFlash, Remoting Debug Headers on OSFlash

Since: 0.1

Submodules [hide private]

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]
 
_read_header(stream, decoder, strict=False)
Read AMF Message header from the stream.
source code
 
_write_header(name, header, required, stream, encoder, strict=False)
Write AMF message header.
source code
 
_read_body(stream, decoder, strict=False, logger=None)
Read an AMF message body from the stream.
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
 
decode(stream, strict=False, logger=None, timezone_offset=None)
Decodes the incoming stream as a remoting message.
source code
BufferedByteStream
encode(msg, strict=False, logger=None, timezone_offset=None)
Encodes and returns the msg as an AMF stream.
source code
 
get_exception_from_fault(fault) source code
Variables [hide private]
  STATUS_OK = 0
  STATUS_ERROR = 1
  STATUS_DEBUG = 2
  STATUS_CODES = {0: '/onResult', 1: '/onStatus', 2: '/onDebugEv...
  CONTENT_TYPE = 'application/x-amf'
  ERROR_CODES = {0: 'Server.Call.Failed'}
  APPEND_TO_GATEWAY_URL = 'AppendToGatewayUrl'
  REPLACE_GATEWAY_URL = 'ReplaceGatewayUrl'
  REQUEST_PERSISTENT_HEADER = 'RequestPersistentHeader'
  ERROR_CALL_FAILED = 0
  __package__ = 'pyamf.remoting'

Imports: pyamf, util


Function Details [hide private]

_read_header(stream, decoder, strict=False)

source code 

Read AMF Message header from the stream.

Parameters:
  • decoder - An AMF0 decoder.
  • strict - Use strict decoding policy. Default is False. Will raise a pyamf.DecodeError if the data that was read from the stream does not match the header length.
  • stream (BufferedByteStream)
Returns:
A tuple containing the name of the header, a bool determining if understanding this header is required and the decoded data.

Note: Quite what understanding required headers actually means is unknown.

_write_header(name, header, required, stream, encoder, strict=False)

source code 

Write AMF message header.

Parameters:
  • name - Name of the header.
  • header - Header value.
  • required - Whether understanding this header is required (?).
  • stream - BufferedByteStream that will receive the encoded header.
  • encoder - An encoder capable of encoding AMF0.
  • strict - Use strict encoding policy. Default is False. Will write the correct header length after writing the header.

_read_body(stream, decoder, strict=False, logger=None)

source code 

Read an AMF message body from the stream.

Parameters:
  • decoder - An AMF0 decoder.
  • strict - Use strict decoding policy. Default is `False`.
  • logger (A logging.Logger instance or None.) - Used to log interesting events whilst reading a remoting body.
  • stream (BufferedByteStream)
Returns:
A tuple containing the id of the request and the Request or Response

_write_body(name, message, stream, encoder, strict=False)

source code 

Write AMF message body.

Parameters:
  • name - The name of the request.
  • message - The AMF Message
  • encoder - An AMF0 encoder.
  • strict - Use strict encoding policy. Default is `False`.
  • stream (BufferedByteStream)

_get_status(status)

source code 

Get status code.

See Also: STATUS_CODES

decode(stream, strict=False, logger=None, timezone_offset=None)

source code 

Decodes the incoming stream as a remoting message.

Parameters:
Returns:
Message envelope.

encode(msg, strict=False, logger=None, timezone_offset=None)

source code 

Encodes and returns the msg as an AMF stream.

Parameters:
  • strict - Enforce strict encoding. Default is False. Specifically header/body lengths will be written correctly, instead of the default 0. Default is `False`. Introduced in 0.4.
  • logger (logging.Logger) - Used to log interesting events whilst decoding a remoting message.
  • timezone_offset (datetime.datetime.timedelta<http:// docs.python.org/library/datetime.html#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: BufferedByteStream

Variables Details [hide private]

STATUS_CODES

Value:
{0: '/onResult', 1: '/onStatus', 2: '/onDebugEvents'}