No, I don't think it's entirely safe. A definite to-do for 0.8 will be a public and documented caching interface. If a multiprocess environment you'll probably want to leave caching on (it's pretty important for performance) and then clear the cache at the beginning or end of each request. You can do that with _connection.cache.clear().

I seem to have solved the problem I was seeing earlier, with data getting out-of-sync in-between requests. It looks like either a bug in SQLObject, or a misunderstanding on my part, or a bit of both :) Remember, I am deploying this behind the flup forking WSGI/SCGI server.

I fixed my problem by creating the following filter:

    from cherrypy.lib.filter    import basefilter
    from myproject.model        import hub

    class CacheFilter(basefilter.BaseFilter):
        def beforeMain(self):
            hub.getConnection().cache.clear()           

        def beforeFinalize(self):
            hub.getConnection().cache.clear()

And then I enabled it globally in the cherrypy configuration. Filters are pretty awesome!

Ian, should I have to do this? Turning the cache off completely did *not* seem to solve the problem (?cache=0), whereas this filter did solve the problem.

Sorry for slamming the list today with questions :)

  -- Jonathan

Reply via email to