Quick fix for Trac Babel/Locale issue

Posted: March 10th, 2011 | Author: | Filed under: Trac | Tags: , , | No Comments »

After installing Babel on our development machine, Trac died with that error:
OSError: [Errno 2] No such file or directory: '/usr/local/lib/python2.6/dist-packages/Trac-0.12-py2.6.egg/trac/locale'

The issue seems to be related to #9439: When installing Trac, it checks whether Babel is installed or not. When Babel is installed, Trac also installs the locale files. The problem occurs when Babel is installed after installing Trac, because Trac expects the locale files to exists when Babel is installed.

As I don’t use locale with Trac, I couldn’t delete Babel (because I do use it with other stuff) and I didn’t want to re-install Trac – I took the hacky solution and modified trac/web/main.py so it’ll ignore the fact that Babel is installed and won’t use it at all. This can be done by commenting out the part that tries to import babel and setting the Locale to None manually. Open trac/web/main.py, look for (should be at line 29):

try:
    from babel import Locale
except ImportError:
    Locale = None

and replace with:

#try:
#    from babel import Locale
#except ImportError:
#    Locale = None
Locale = None

Yes – very much hacky, but it works as a quick solution for now, as we must have Trac up and running. I will be looking for a better solution and update this post.


RepoRevisionSyntax: Trac ‘r123′ WikiFormatting syntax for multiple repositories

Posted: August 9th, 2010 | Author: | Filed under: Trac | Tags: , , , , , | No Comments »

Update: this is now part of core. No need to use the plugin if you’re using Trac >=0.12.

We’ve switched to having multiple projects under the same Trac environment (more details on how we set it up will follow), which also means we’re using multiple repositories under the same Trac environment. One implication it has is that when you link to a changeset, you must specify the repository it belongs in addition to the revision number. This can be done using ‘changeset:123/repo’ and ‘[repo/123]‘, but the ‘r123′ syntax has no alternative.

As we find the ‘r123′ syntax more readable than its alternatives, we created a tiny Trac plugin that allows us to use ‘r123repo’ syntax – the repository name is added right after the revision/changeset number. Get it from trac-hacks.