From: Andrew B. <an...@ex...> - 2003-12-07 02:32:52
|
On Wednesday 03 December 2003 11:34 am, you wrote: > On Dec 3, 2003, at 9:03 AM, Andrew Barilla wrote: > > I'm a fairly new user to SQLObject and Webware but I've got my new > > site up and > > running. The only thing is that I have set _cacheValues = False in my > > SQLObjects so that if I update data, it's reflected on the view-only > > part of > > the website. Is this the only way to do this or can I force a refresh > > of the > > cache? I looked through the mailing list archives but couldn't find > > anything > > definite on this topic. > > You can force a cache refresh on any instance by calling .refresh(), or > .expire() to cause a refresh sometime in the future (when the instance > is used again). > > When you want to expire a whole batch, you'll just run through the > objects and do this. DBConnection.Transaction.rollback does this, as a > model. > > -- > Ian Bicking | ia...@co... | http://blog.ianbicking.org The DBConnection.Transaction.rollback code pointed me in the right direction and with some code I found in the mailing list archives, I modified the SQLObject class to include this method. def expireAll(cls): Caches = cls._connection.cache.allSubCaches() subCaches = [(sub, sub.allIDs()) for sub in Caches] for subCache, ids in subCaches: for id in ids: inst = subCache.tryGet(id) if inst is not None: inst.expire() expireAll = classmethod(expireAll) It's working for everything except one of my objects that's used to fill a FormKit dropdown box. That must be cached somewhere else, but it's not that big of a deal. Thanks for your help, Andy |