List repositories from multiple projects in Trac using mod_python
- by Steffen Eriksen
Currently working on a customized webpage that shows the available projects I have in Trac (1.0.1). I am using mod_python to connect the trac interface. I found a standard page for this, but it didn't show listing of repositories. The page showed some variables to link to the different projects, but I can't find variables to the different repositories inside the projects.
I have set up the webpage from reading this: http://trac.edgewall.org/wiki/TracInterfaceCustomization
(under Site Appearance)
Short summary; editing ../conf.d/trac.conf:
PythonOption TracEnvParentDir /parent/dir/of/projects
PythonOption TracEnvIndexTemplate /path/to/template
And making a template file I can edit at /path/to/template:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<head>
<title>Available Projects</title>
</head>
<body>
<h1>Available Projects</h1>
<ul>
<dl>
<li py:for="project in projects" py:choose="">
<a py:when="project.href" href="$project.href"
title="$project.description">$project.name</a>
## <dd> WANT TO ADD CODE HERE! </dd>
<py:otherwise>
<small>$project.name: <em>Error</em> <br /> ($project.description)</small>
</py:otherwise>
</li>
</dl>
</ul>
</body>
</html>
So... The code I want to add is something like:
<dd py:for="repos in project.repository" py:choose="">
<a py:when="repos.href" href="$repos.href"> $repos.name</a> </dd>
I can't figure out where to add the variables, or if there already exists some variables I can use. After searching through the files it seemed like main.py had something to do with the variables (/usr/local/Trac-1.0.1/trac/web/main.py), but at first look it didn't seem easy to just add more variables.
Is there a simple way to find the rest of the variables ? And how hard is it to add more variables? Will it perhaps be easier to do this an alternative way ? All I need is to link to the repositories dynamically