views:

69

answers:

2

I periodically get this problem where all of a sudden mako is using old versions of templates, and it's not until I manually go and update the template files that they'll use the current version. I'm using

./manage.py runserver

I think it's usually after I update using source control, but it's intermittent, and I can't reliably reproduce the problem.

A: 

It kinda feels like there some caching going on. You don't give a very specific description of the process, so it's hard to go any deeper than that.

Peter Rowell
Yeah, this is a frustrating one because I haven't been able to reliably reproduce the problem, hence I don't know what the process is yet. As you suggest, something seems like it's cached somewhere, but I have no idea who's caching what where.
Dave Aaron Smith
I haven't used mako, but I did find this: http://www.makotemplates.org/docs/caching.html. Good luck.
Peter Rowell
A: 

In your settings.py file you can use the MAKO_TEMPLATE_OPTS setting to specify where the temporary compiled templates go.

import os
import tempfile
MAKO_TEMPLATE_OPTS=dict(input_encoding='utf-8',
                        module_directory=os.path.join(
    tempfile.gettempdir(),
    os.environ.get('LOGNAME', 'unknown_user'),
    'mako'))

This will put them somewhere like /tmp/dsmith/mako

You can use different folders for different projects to make sure they don't overlap. Also, if you notice the problem after a source control update or something you can just clear out the cached folder.

Dave Aaron Smith