[Twisted-web] Twisted and SQLAlchemy Cache Problem

Magnus Hult magnus at spotify.com
Wed Jun 13 08:40:11 EDT 2007


When executing the following program, changes in the database (other
than those made by this program) aren't visible until it is restarted,
due to some form of SQLAlchemy caching:

from twisted.web import server, resource
import model # my database model

class MyRoot(resource.Resource):
  def render(self, request):
    m = model.MyModel.get(request.args['id'][0])
    return m.some_column

# Connect to database.

# Create site structure.
root = resource.Resource()
root.putChild('', MyRoot())
site = server.Site(root)

# Switch user, start service.
from twisted.application import service, strports
application = service.Application("myexample")
s = strports.service('tcp:8080', site)

So if I visit http://localhost:8080/?id=1, then alter the some_column
value for the row who's id is 1 and reload, the change is not

Problem is, I need the update to be visible. How would I go about
implementing this?


More information about the Twisted-web mailing list