TracRPC plugin development setup
This post is just a summary of how to get a separate TracRPC Python development environment configured.
It presumes you have Python, Subversion and Python-Subversion bindings installed already. Other than that, it depends on virtualenv, a great way of making completely separate Python installations for test and development.
1. Make a virtualenv
simon: ~ > cd dev simon: ~/dev > virtualenv tracrpc New python executable in tracrpc/bin/python Installing setuptools............done. simon: ~/dev > source tracrpc/bin/activate (tracrpc)simon: ~/dev >
We are now running the virtual python.
2. Get Source
We want a recent stable Trac, and TracRPC development depends on running Trac for source so we neeed to do a checkout. Also, we want to checkout the TracRPC sourcecode itself.
(tracrpc)simon: ~/dev > mkdir tracrpc/src (tracrpc)simon: ~/dev > cd tracrpc/src (tracrpc)simon: ~/dev/tracrpc/src > svn co http://svn.edgewall.org/repos/trac/branches/0.12-stable trac ..... [snip] ..... Checked out revision 10122. (tracrpc)simon: ~/dev/tracrpc/src > svn co http://trac-hacks.org/svn/xmlrpcplugin/trunk tracrpc ..... [snip] ..... Checked out revision 9092.
Installing is done using develop mode, which means that we are running the modules and scripts from the checkout - without building and installing eggs to a separate location.
(tracrpc)simon: ~/dev/tracrpc/src > cd trac (tracrpc)simon: ~/dev/tracrpc/src/trac > python setup.py develop ..... [snip] ..... Finished processing dependencies for Trac==0.12.1dev-r10122
(tracrpc)simon: ~/dev/tracrpc/src/trac > cd ../tracrpc (tracrpc)simon: ~/dev/tracrpc/src/tracrpc > python setup.py develop ..... [snip] ..... Finished processing dependencies for TracXMLRPC==1.1.0-r8688
4. Run Tests
The functional Trac test suite uses twill, so that also becomes a dependency for the plugin tests. Install that first:
(tracrpc)simon: ~/dev/tracrpc/src/tracrpc > easy_install twill ..... [snip] ..... Finished processing dependencies for twill
All should now be installed and working, and to make sure lets run the TracRPC tests:
(tracrpc)simon: ~/dev/tracrpc/src/tracrpc > python setup.py test ..... [snip] ..... Found Trac source: /Users/simon/dev/tracrpc/src/trac Enabling RPC plugin and permissions... Created test environment: /Users/simon/dev/tracrpc/src/tracrpc/rpctestenv Starting web server: http://127.0.0.1:8765 ..... [snip] ..... Ran 32 tests in 42.156s OK Stopping web server...
Following a testrun, there is a complete working Trac project with Subversion repository in src/tracrpc/rpctestenv. This is useful for a number of reasons...
- The project has debug logging enabled for the testrun, so by inspecting rpctestenv/trac/log/trac.log you can see all that happened server-side while executing the tests. The tests run in sequence, and there should be markers in the log indicating where each new tests starts.
- You can run the trac environment, and access as anonymous or login using the user:user or admin:admin users created and used in testing:
(tracrpc)simon: ~/dev/tracrpc/src/tracrpc > tracd --port=8888 --basic-auth="/,rpctestenv/htpasswd,trac" rpctestenv/trac
- Running the Trac environment also means you can access the project using a client-side library, like the one from Python standard library - from a new shell:
>>> import xmlrpclib >>> server = xmlrpclib.ServerProxy("http://admin:admin@localhost:8888/trac/login/xmlrpc") >>> print server.wiki.getPage('TitleIndex') = Welcome to Trac 0.12.1dev = ..... [snip] .....