SqlAlchemy + Flask + Apache mod_wsgi strange caching
- Romeo Mihalcea
- 2012-09-22 @ 18:01
I have a relatively small application with a very weird behavior when
running in production. The code runs on Apache/mod_wsgi. On one of the page
I show the user how many downloads (of a certain resource) he is allowed to
perform. The downloads count is taken from the orders table which contains
an integer field called downloads_purchased. I then select all orders
active (no older than 30 days) abd perform a SUM on the
`downloads_purchased` field to determine what's the user's limit.
All nice and simple but...when I add a new order and the user loggs in, he
can see the order under his account just that, the query which determines
how many downloads he has left still shows 0 even though I just added him
an order. Since he can see the order this means it was commited so it's not
a commit issue with sqlalchemy. If I restart apache and tell the user to
refresh the page the query returns the right number of downloads left.
Any idea where this bug might sit? It's driving me nuts already. I don't
even know what code to show since everything is commited and my sql alchemy
sessions seem to be working fine since the user can see the new order.