Action Message Format RPC

Action Message Format (AMF) is a binary format used for serializing ActionScript objects. It's primarily used for communication between Flash and a server, though it can be used from clients in other languages as well.

AMF support is provided by utilizing the PyAMF package.

pyramid_rpc exposes AMF as a Remoting gateway in a similar manner to PyAMF's Django gateway support. This allows a remoting gateway to be exposed as a normal Pyramid view.

Exposing AMF Services

Exposing functions for AMF remoting is done by setting up standard AMF functions and defining a gateway view:

# yourproject/amfgateway.py

from pyramid_rpc.amfgateway import PyramidGateway

def echo(request, data):
    return data

services = {
    'myservice.echo': echo
    # could include other functions as well
}

echoGateway = PyramidGateway(services)

Then expose the gateway as if it was a standard Pyramid view:

# yourproject/run.py

from pyramid.config import Configurator
from paste.httpserver import serve

if __name__ == '__main__':
    config = Configurator()
    config.add_view('amfgateway.echoGateway')
    app = config.make_wsgi_app()
    serve(app, host='0.0.0.0')

The request passed into the service function is the standard Pyramid request object. It can be disabled by passing expose_request=False into the PyramidGateway instantiation.

API

Public

Pyramid View Gateway implementation.

A PyramidGateway instance implements a Pyramid view compatible callable object, allowing it to be configured like any other Pyramid view.

class PyramidGateway(*args, **kwargs)[source]

Pyramid View Remoting Gateway

Parameters:
  • expose_request -- Defaults to True. Whether or not the service function should be called with the Pyramid request object.
  • debug -- Boolean toggling debug mode.