[Trac] Understanding API and chrome syntax

Emmanuel Blot manu.blot at gmail.com
Tue Aug 9 12:13:22 CDT 2005


> Well, it'll take some time but i'm sure i'll get the hang of how to manage
> the required extensions. And perhaps you or somebody else has got a couple of
> additional information resources concerning python/clearsilver which you
> would like to share.

It might save you some hassle, as it has not been obvious for me (I
should add a note to the Plugin page, perhaps). If you write an
extension plugin, there are some things you might want to know.

I'm not really sure I choose the proper way to work around, so I hope
cmlenz will correct me here - it's both an answer and question session
;-) :

 * don't use the 'plugins' directory located in your project
directory, if you're not using PythonEggs. I'm not. Use another
directory, and specify this new path in the plugin entry
(conf/trac.ini file, see TracDev for syntax), along with the name of
your plugin
 * use a subdirectory to store the plugin code, ie
plug-in/theme/file.py, not plug-in/file.py. I got some errors with the
initial releases of the loader, I'm not sure if this is fixed by now.
 * don't forget to define an __init__.py file along with your plug-in
file, or the loader won't be able to load it.
 * use CGI-based trac setup to develop your plug in. mod_python does
not reload the python file until the server is restarted, tracd has to
be stopped/started each time you change a file as well. CGI does not
suffer from this issue, as everything is reloaded on each client
request. This makes it really, really slow, but for dev. purpose
that's ok. BTW, you need to take care about the lifespan of objects.
Many objects are persistent over user requests.
 * put any custom ClearSilver template file into your project
templates file (ie where site_{header/footer}.cs are located.
 * I don't think it is possible to use add_stylesheet method (CSS
file) and a custom directory. This would have to be addressed at some
point.
 * About Clearsilver: remember that Trac provides a wrapper to fill in
the HDF template, which is, I believe, easier to use than the bare
Clearsilver python API: web/clearsilver.py/HDFWrapper

Cheers,

-- 
Manu


More information about the Trac mailing list