mattdorn.com

Generously funded by Matt Dorn

Trac + Darcs + reStructuredText

with one comment

Edgewall Software’s Trac seems to have become something of a standard for agile management of software projects both within the Open Source community and within closed organizations, and after having the opportunity to use it on a recent project, I can appreciate why. It’s simple to setup and manage, and its self-described "minimalistic approach to web-based software project management" is exactly along the lines of my own philosophy.

For that project I used a default setup with a Subversion repository, and composed Wiki pages using the default Wiki markup. While Subversion is obviously a standard, for personal projects I prefer to use the distributed versioning system Darcs, and I usually insist on doing the majority of my text composition in reStructuredText. So when I found out that there was a Darcs plugin for Trac and that it also supports reStructuredText , I got motivated to get a couple of my own projects up and running. What follows is a brief description of the steps I took to do so.

1   Get the software

I’m assuming your system has fundamentals like Python and Apache installed. In addition:

  • Trac (I’m using v0.10.x)

  • Darcs (I’m using v. 1.0.8)

  • sqlite2 (I personally had problems with version 3 and the Darcs plugin on a Fedora Core 4 system, which have been reported to the project maintainers)

  • Trac plugins
  • Python docutils (for reStructuredText support)

  • SilverCity (for syntax coloring of your code)

  • Python setuptools (for working with Trac plugins)

  • Apache mod_python

Note that the items that are not linked above should be available via the package manager of most modern Linux systems. You’ll want to install everything except that Trac plugins before moving on to the next step.

2   Set up your Trac instance

Create a directory where you want to maintain your Trac projects and use the trac-admin command to create the instance and associate it with your Darcs repository:

trac-admin /path/to/MyProject initenv "My Project" sqlite:db/trac.db darcs /path/to/repo /usr/share/trac/templates/

The instance is successfully created, but you’ll get a warning that Trac is not supported. That’s because you haven’t setup the plugins yet.

3   Install and configure the Trac plugins

Download the source for each plugin into a temporary directory. Trac handles plugins in the Python "egg" format. So in the source directory of each, run the following command:

python setup.py bdist_egg

That will create a file with a .egg extension in the dist directory of the plugin you’ve downloaded, which you can now copy to the plugins directory of your new Trac instance. Be sure to copy all three of them.

Now you need to update your Trac instance to understand the Darcs plugin:

trac-admin /path/to/MyProject upgrade
trac-admin /path/to/MyProject resync

Finally, add the following to the conf/trac.ini file of your instance, under the [components] section:

[components]
trac.web.auth.LoginModule = disabled
acct_mgr.web_ui.LoginModule = enabled
trac.ticket.report.* = disabled

You may wish to test your instance now, using Trac’s built-in Web server, and browsing to localhost:8000:

tracd --port 8000 /path/to/MyProject

or:

/usr/sbin/tracd --port 8000 /path/to/MyProject

Make sure you can browse your Darcs repo to confirm that the Darcs plugin is working. If you’re not seeing syntax highlighting, check to make sure SilverCity has been installed correctly.

In this setup, however, we’ll ultimately be using Apache and mod_python to server the instance, and a few extra steps are needed.

4   Configure Apache and mod_python

Trac’s documentation on mod_python is mostly adequate, with one exception. You need to identify a cache directory for your instance’s egg plugins. In your Location directive, composed in accordance with that documentation, including the following line should be sufficient:

SetEnv PYTHON_EGG_CACHE /tmp/trac-eggs

For the sake of completeness, the Location directive inside the VirtualHost setup for your site should look something like this, if you have multiple Trac instances:

<Location /projects>
  SetHandler mod_python
  PythonHandler trac.web.modpython_frontend
  PythonOption TracEnvParentDir /path/to/my/trac/projects
  SetEnv PYTHON_EGG_CACHE /tmp/trac-eggs
  PythonOption TracUriRoot /projects
</Location>

Finally, the user under which Apache is run will need read and write access to the following directories in your instance:

  • db
  • attachments
  • log

5   Configure user authentication and permissions

By default, Trac allows the anonymous user access to nearly everything, so you’ll want to make some changes. Fortunately the Web Admin and Account Manager plugins make this fairly easy to do. Before you create any user accounts, I found it was easiest simply to start by adding the TRAC_ADMIN permission to the anonymous group via the command line admin tool:

trac-admin /path/to/projenv permission add anonymous TRAC_ADMIN

Once I have access to the "Admin" button in the Web interface as anonymous I performed the following:

  1. In Accounts > Configuration, identify the path to the HtPasswdStore. Ideally this will probably be a location within your instance. The Web server user will need to be able to write to the location.
  2. In Accounts > Users, add a user. Note that you could also add a user by registering yourself via the "Register" link that should appear after having installed the Account Manager plugin.
  3. In General > Permissions, create an "admin" group in the "Add Subject to Group" box.
  4. In the same box, add the newly created user to the admin group.
  5. Now, remove any "CREATE" or "DELETE" or write-related permissions, especially TRAC_ADMIN, from the anonymous subject.
  6. Using the "Grant Permission" box, add anything appropriate for your setup to the "authenticated" subject. Make sure the TRAC_ADMIN permission is assigned to the newly created admin group.
  7. Add any other groups appropriate to your project (e.g., developers, who would probably have access to everything except TRAC_ADMIN)

6   Final notes

It’s up to you to configure your ticket system with the appropriate values for components, milestones, versions, etc.

6.1   Darcs+Tracs bug

Note that the only major bug with the Darcs plugin that I’ve found is the broken "view changes" button. That will need to be fixed before Trac+Darcs is a completely legitimate product.

6.2   reStructuredText in Trac

Composing your Wiki pages in RST simply requires you to enclose your text with the following syntax:

{{{
#!rst

Your text goes here.

}}}

That’s an inconvenience, however minor, and I think a great Trac enhancement (which too my knowledge has not yet been suggested) would be the ability to set a default markup syntax in the configuration file.

Written by mdorn

February 1st, 2007 at 10:50 am

One Response to 'Trac + Darcs + reStructuredText'

Subscribe to comments with RSS or TrackBack to 'Trac + Darcs + reStructuredText'.

Leave a Reply