Re: [Zope] Problem with constructTransientObjectContainer - Resolved

2006-06-22 Thread Jean Jordaan
Hi Jonathan

 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).

Can't you just put the images in the TOC and let them expire by themselves?

-- 
jean
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Problem with constructTransientObjectContainer - Resolved

2006-06-22 Thread Jonathan


- Original Message - 
From: Jean Jordaan [EMAIL PROTECTED]

To: zope@zope.org
Sent: Thursday, June 22, 2006 11:32 AM
Subject: Re: [Zope] Problem with constructTransientObjectContainer - 
Resolved




Hi Jonathan


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).


Can't you just put the images in the TOC and let them expire by 
themselves?



I need to be able to allow client browsers to access the images via an html 
img src=... tag.


I didn't know how to construct a url to get at the image objects within a 
TOC (can this be done?)



Thanks,

Jonathan




___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Problem with constructTransientObjectContainer - Resolved

2006-06-21 Thread Chris Withers

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...


Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Problem with constructTransientObjectContainer - Resolved

2006-06-21 Thread Jonathan


- Original Message - 
From: Chris Withers [EMAIL PROTECTED]

To: Jonathan [EMAIL PROTECTED]
Cc: Chris McDonough [EMAIL PROTECTED]; 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 


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Problem with constructTransientObjectContainer - Resolved

2006-06-20 Thread Jonathan


- Original Message - 
From: Chris McDonough [EMAIL PROTECTED]
folder.manage_addProducts ['Transience'].constructTransientObjectContainer 
might work (assuming  constructTransientObjectContainer is the right 
constructor name, I  didn't check).


Chris, thanks for the idea - I tried it, but  it generated the error: 
BadRequest: ('Empty or invalid id specified', Folder at /Coz/WUI)


After looking at the Transience.py source I found the answer:  Instead of 
passing 'self' as the first parameter I passed the folder object instead. 
The worked because constructTransientObjectContainer does: 
self._setObject(id, ob)


So the final solution was:

   folder = self.restrictedTraverse('Coz/TempImages')
   constructTransientObjectContainer(folder, 'GarbageCollector', 
timeout_mins=10, limit=0,

   delNotification=BASEFOLDER+'DeleteTempImage')


Thanks again for the help, it got me thinking in the right direction!


Jonathan

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )