Chris McDonough wrote:
There is a TemporaryFolder class in Zope. It's in lib/python/Products/TemporaryFolder.py and its named MountedTemporaryFolder. I recommend against subclassing MountedTemporaryFolder unless you want to spend the time to understand ZODB "mounting".
Actually, I got it working by inheriting from ObjectManager and simply *containing* a Temporary Folder. I'm not sure if that was strictly necessary, but I like it better this way anyway (for one thing, it makes it possible to query the cache independently of my __getattr__ overload which is one of those "kids don't try this at home" techniques ;-D, so its good to minimize the impact as much as possible).
A temporary folder is an object that is a mount point. It mounts a TemporaryStorage-backed database and masquerades as its root object. When you traverse one of these things, the __of__ method of the mount point object is called, and that returns the a Folder object that actually lives in another ZODB. To understand it fully, you'd need to read the source of TemporaryFolder.py and MountPoint.py.
Chris, I know "beggars can't be choosers", but seriously, I think it would be a big improvement of the code to put the above text into a nice sweet little comment block inside TemporaryFolder.py. The existing comments are inadequate (this is an amazing understatement). It will do exactly as you wrote it. <rant> Yes, it's open-source. Yes, no one is paying you for it. So what? You released it because you want it to be used and improved. You want people to help you with it. You want people to document it for you (also for free, I might add). And you don't really want to waste your time answering the same questions over and over again. So why are you shooting yourself in the foot by making it difficult for them? Comments are cheap, and a real bargain in the long run. </rant>
But I honestly don't think using a TemporaryFolder for this is the right thing here. Your object should return different images when different methods are called on it, and each method should have its own URL.
Each image *does* get a separate URL. Downstream caches can take advantage of this. And yes, that's why I did it that way. Anyway I disagree on the design decision. No offense, but I have to live with it, so I'll gamble on my own judgement. Anyway -- thanks for the description of how TemporaryFolder is meant to work. And I guess you must be the author of the module itself, in which case, thanks for that too, it's a nice addition to Zope. VarImage now passes my stress test, which is to ask for a page with 300 different sizes of the same image (this mainly tests the conflict problem that arises when a single storage location is used). Cache performance is good -- the second request for the same page is very quick indeed (this tests the scaling performance). So I'm a happy camper. We'll have a copy on our project site at Sourceforge sometime soon, if anyone would like to use a freely-resizing image type in Zope, we've found it quite useful in the design process: http://sourceforge.net/projects/spacelift (I separated VarImage out into a separate product for easier testing and because it's probably useful for more than just Narya). Thanks, Terry -- ------------------------------------------------------ Terry Hancock hancock@anansispaceworks.com Anansi Spaceworks http://www.anansispaceworks.com P.O. Box 60583 Pasadena, CA 91116-6583 ------------------------------------------------------