Saturday, June 02, 2007

Something looks like a Pylons caching problem...

...but isn't.

For a while now, in my in-development Pylons web app, I've been experiencing what I thought were cache problems. Every X clicks of the refresh button (usually 5 or 10) the page would revert to an older version. I thought this might be some middleware playing tricks on me... but it wasn't. Well not quite.

I use some custom SQLAlchemy magic in my model to dynamically switch between SQLite databases based on the URL, yet still keep the 'core' database available in the same model namespace. The code to setup the correct SQLAlchemy sessions sits in the __before__ method of lib.base.BaseController. As it turns out, I also need to call session.clear() on my SA session object between requests, as it seems some junk is left around, waiting to trick the unwary programmer.

This problem was solved with the help of Band of None and their new tune, Your Myspace Page.






1 comment:

scoutr said...

thank you, thank you, thank you.

i was banging my head against that for awhile--

i'm using pylons as a backend for adobe flex, and i was *convinced* that the datagrid was retarded.

but alas, clearing the session fixes everything.

sigh. 8 hours gone!

Popular Posts