|Version 7 (modified by 11 years ago) (diff),|
Trac XML-RPC Plugin
* Please note that this is still alpha software, so the API may change *
This plugin allows Trac plugins to export select parts of their interface via XML-RPC.
It also includes some exported functions for manipulating tickets, with plans to include interfaces to other parts of Trac's API.
The browseable XML-RPC URI suffix is /RPC2, however most XML-RPC clients should use the authenticated URI suffix /login/RPC2 as this is correctly authenticated by Trac.
If the HTTP request to this URI is not XML, the XmlRpcPlugin will list all exported functions that the current user has permission to use.
Unfortunately, due to some issues with mod_pythons FieldStorage emultation layer, this plugin requires the patch in [trac-ticket:2509 #T2509] to be applied to your Trac installation.
Once this patch has been applied, install in the same manner as any other Trac plugin:
# python setup.py bdist_egg # cp dist/*.egg /srv/trac/env/plugins
If you have any issues, create a new ticket.
Download the zipped source from [download:xmlrpcplugin here].
Obtain a list of XML-RPC exported functions available to my user:
import xmlrpclib server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/RPC2") print server.tracrpc.api.list_xmlrpc_functions()
List all tickets that are owned by athomas:
import xmlrpclib server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/RPC2") print server.tracrpc.ticket.query_tickets("owner=athomas")
Export a "hello world' function:
from tracrpc.api import IXMLRPCProvider from trac.core import Component, implements class HelloWorld(Component): implements(IXMLRPCProvider) def hello_world(self): return "Hello world" def get_xmlrpc_functions(self): yield ('WIKI_VIEW', self.hello_world)