----- Original Message ----- From: "Chris Withers" <chris@simplistix.co.uk> To: "Jonathan" <dev101@magma.ca> Cc: "Chris McDonough" <chrism@plope.com>; <zope@zope.org> Sent: Wednesday, June 21, 2006 6:25 AM Subject: Re: [Zope] Problem with constructTransientObjectContainer - Resolved
Jonathan wrote:
folder = self.restrictedTraverse('Coz/TempImages') constructTransientObjectContainer(folder, 'GarbageCollector', timeout_mins=10, limit=0, delNotification=BASEFOLDER+'DeleteTempImage')
Be careful, I see a lot of hints in there that make me nervous. I'm of the opinion that if you think you need to use a TOC, you're probably doing something wrong...
The use case: the zodb contains small image objects which need to have a custom overlay (done with PIL) before being presented to the user. Each overlay is unique. Each customized image is only shown to a single user once, then it is discarded. In order to eliminate many writes to the zodb (disk), I have decided to put the customized images into a temporary folder (RAM). In order to delete the customized images I have created a TOC to act as a 'GarbageCollector'. Whenever a customized image is written to the temporary folder, an entry containing the image object id is placed in the TOC. When the TOC 'times-out' an entry a script (external method) acquires the object id from the TOC entry and deletes the customized image from the temporary folder. This seems to be working... so far ;-) What 'hints' are making you nervous? Is there a 'better' way to do this? Jonathan