Edit me on GitHub

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()
    app = config.make_wsgi_app()
    serve(app, host='')

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.



Table Of Contents

Previous topic


Next topic

Developing Additional RPC Support