Version 1 (modified by athomas, 9 years ago) (diff)


Migrating Trac macros from 0.8.x to 0.9.x

Global macros are now stored in ${prefix}/share/trac/wiki-macros instead of ${prefix}/pythonX.Y/site-packages/trac/wiki-macros.

Global macros are not implicitly loaded. After installing a macro into the global macro directory a trac-admin <env> upgrade must be performed, which will copy the macro into the environments <env>/wiki-macros directory. Unfortunately, trac does not appear to detect outdated macros and will not upgrade existing macros to newer versions. You will need to manually delete the copies of the global macros in each environment, then perform an environment upgrade. With mod_python, as always, this will require an apache restart.

If your macro needs to preserve state across an entire page render, place the state variables into the hdf object.

Several classes and functions used frequently in macros have changed. This table outlines some of those that I came across while migrating my macros to the 0.9.x object hierarchy:

0.8.xEquivalent in 0.9.x
trac.WikiFormatter.wiki_to_oneliner(wikitext, hdf, env, db,absurls=0), env, db=None, absurls=0)
|trac.WikiFormatter.wiki_to_html(wikitext, hdf, env, db, absurls=0), env, req, db=None, absurls=0, escape_newlines=False)