views:

136

answers:

2

I recently jumped on a project using Pylons. I'm not familiar with either Python or Pylons, but I haven't had very much trouble getting the hang of things.

Pylon projects seem to cache templates indefinitely by default and I can't figure out a way to clear the cached templates (stored by default in /data/templates) except by manually deleting them and restarting the server.

Better yet, can template caching be disabled?

The page, http://wiki.pylonshq.com/display/pylonsdocs/Caching+in+Templates+and+Controllers, on template caching doesn't seem helpful and there's a brief mention of disabling cache globally by setting in the .ini file:

cache_enabled = false

But it doesn't seem to work.

This should be relatively straight-forward, shouldn't it?

A: 

false should be uppercased to False -- and if it still doesn't work when you do that, adding a comment to that page (pointing out the doc error, or bug as the case may be) is appropriate (it may simply be that mako's template caching is not using beaker, in which case it's just a lack of clarity in the docs).

Per Mako's docs, you should also be able to invalidate it with the invalidate method of the cache objects, and/or disable it for a template with <%page cached=False%>.

Alex Martelli
Thanks for the quick response!The true/false values in the configuration files are case-insensitive.
James
+1  A: 

The problem was entirely something else..

Pylons always caches templates, but updates its template cache automatically by comparing the last-modified timestamp of the template and its cached version. The problem had to do with synchronizing the server's clock with real time.

It was a couple minutes ahead and uploads from my computer (with a synchronized clock) would pull the template's timestamp back a couple of minutes; Pylons would interpret that as the template being older than the cached version and not update the cache.

James
I recommend installing ntp to keep the clock accurate.
Marius Gedminas