Version 35 (modified by 18 years ago) (diff) | ,
---|
Trac XML-RPC Plugin
Description
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 browsable XML-RPC URI suffix is /xmlrpc, however most XML-RPC clients should use the authenticated URL suffix /login/xmlrpc as this is correctly authenticated by Trac.
WikiRPC API is complete, mostly thanks to mgood.
Ticket API is also complete, with the following types exported: component, version, milestone, type, status, resolution, priority and severity.
For example, for TracHacks the URIs are http://trac-hacks.org/xmlrpc and http://trac-hacks.org/login/xmlrpc (must be authenticated).
Todo
Outstanding tasks are roadmap, timeline, user management (?), plugin management (?)...plus probably more.
Installation
This plugin requires the current trunk of Trac ([T2997] as of this writing). It will not work with Trac 0.9.x or earlier.
Install in the same manner as any other Trac plugin:
# python setup.py bdist_egg # cp dist/*.egg /srv/trac/env/plugins
You will also probably need to enable the plugin in your environments trac.ini:
[components] tracrpc.* = enabled
Bugs/Feature Requests
Existing bugs and feature requests for XmlRpcPlugin are here.
If you have any issues, create a new ticket.
Download
Download the zipped source from [download:xmlrpcplugin here].
Source
You can check out the source for XmlRpcPlugin using Subversion from here or browse the source with Trac.
Example
End-User Usage
Obtain and print a list of XML-RPC exported functions available to my user:
import xmlrpclib server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/xmlrpc") for method in server.system.listMethods(): print method print '\n'.join([' ' + x for x in server.system.methodHelp(method).split('\n')]) print print
The same example using system.multicall()
. This reduces network and server
load by compacting all of the system.methodHelp()
calls into one HTTP POST.
import xmlrpclib server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/xmlrpc") methods = server.system.listMethods() method_help = server.system.multicall([{'methodName': 'system.methodHelp', 'params': [method]} for method in methods]) for help in method_help: lines = help.splitlines() print lines[0] print '\n'.join([' ' + x for x in lines[2:]]) print
List all tickets that are owned by athomas, using the XML-RPC multicall system to issue multiple RPC calls with one HTTP request:
import xmlrpclib server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/xmlrpc") tickets = server.ticket.query("owner=athomas") print '\n'.join(map(str, server.system.multicall([{'methodName' : 'ticket.get', 'params' : [ticket]} for ticket in tickets])))
Access the Wiki with WikiRPC
import xmlrpclib server = xmlrpclib.ServerProxy("http://athomas:password@localhost/trac-dev/login/xmlrpc") # print the content of WikiStart print server.wiki.getPage("WikiStart") # print WikiStart as HTML print server.wiki.getPageHTML("WikiStart") # write to the SandBox page from a text file sandbox_content = file("sandbox.txt").read() server.wiki.putPage("SandBox", sandbox_content, {"comments": "testing the WikiRPC interface"})
API Usage
Screenshot
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.
http://trac-hacks.org/attachment/wiki/XmlRpcPlugin/tracrpc.png?format=raw
Change Log
- 18591 by jun66j5 on 2023-11-13 14:11:04
-
XmlRpcPlugin: use Trac 1.6 rather than 1.5.4 in tox.ini
- 18521 by jun66j5 on 2023-03-13 21:34:23
-
XmlRpcPlugin: twill and fcrypt are no longer needed for running tests
- 18520 by jun66j5 on 2023-03-13 01:43:21
-
XmlRpcPlugin: add branch for Trac 0.11
- 18519 by jun66j5 on 2023-03-13 00:33:15
-
XmlRpcPlugin: suppress code style warnings (closes #14216)
- 18518 by jun66j5 on 2023-03-12 23:40:57
-
XmlRpcPlugin: add tests for adding large attachment (refs #10875)
(more)
Author/Contributors
Attachments (2)
- tracrpc.png (94.4 KB) - added by 18 years ago.
-
trac_xml_rpc_example_java.zip (92.8 KB) - added by 16 years ago.
java interfaces and proxy class implementation (alpha example)
Download all attachments as: .zip