Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
189 lines (128 sloc) 4.37 KB

Documentation for pyramid_xmlrpc

XML-RPC support for the :mod:`pyramid` web framework.

:mod:`pyramid_xmlrpc` Installation

:mod:`pyramid_xmlrpc` is a package that ships outside the main :mod:`pyramid` distribution. To install the package, use easy_install:

easy_install pyramid_xmlrpc

Or obtain the packge via and use install.

:mod:`pyramid_xmlrpc` Usage

XML-RPC allows you to expose one or more methods at a particular URL. :mod:`pyramid_xmlrpc` has a simple usage pattern for exposing a single method at a particular url, and a more complicated one for when you want to expose multiple methods at a particular URL.

Exposing a single method

Create a function in the form below. The function will be meant to be called with positional parameters from an XML-RPC request.

Then add the :func:`~pyramid_xmlrpc.xmlrpc_view` decorator to the function.

Then configure your application registry to point to the say_hello view.

Using imperative code in your application's startup configuration:

Using ZCML:

Or using a view_config decorator:

Then call the function via an XML-RPC client. Note that any XML-RPC methodName will be ignored; you must point the client directly at the view URL; traversal doesn't work from there.

Exposing multiple methods

If you have multiple methods to expose at a particular url, you should group them together in a class. Think of this class in the same way as you would when you implement a normal :mod:`pyramid` view as a class rather than a function.

The methods of the class will be those exposed as methods to XML-RPC. Not that XML-RPC only supports positional parameters.

To make this view class handle incoming XML-RPC requests, you simply need to subclass the :class:`~pyramid_xmlrpc.XMLRPCView` class. :class:`~pyramid_xmlrpc.XMLRPCView` provides a :meth:`~pyramid_xmlrpc.XMLRPCView.__call__` method, so make sure that your class doesn't provide one!

For example:

This class can then be registered with :mod:`pyramid` as a normal view.

Using imperative code in your application's startup configuration:


The methods exposed by this view can now be used by any XML-RPC client:

API Documentation for :mod:`pyramid_xmlrpc`

.. automodule:: pyramid_xmlrpc

  .. autofunction:: xmlrpc_view

  .. autoclass:: XMLRPCView
     :members: __call__

  .. autofunction:: xmlrpc_marshal

  .. autofunction:: xmlrpc_response

  .. autofunction:: parse_xmlrpc_request

Indices and tables