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 )


[Zope] Problem with constructTransientObjectContainer

2006-06-20 Thread Jonathan



I have an external method that is trying to create 
a Transient Object Container in a 'temp_folder', as follows:

def BuildGarbageCollector(self):
 folder = 
self.restrictedTraverse('Coz/TempImages') 
# Coz/TempImages already exists
 
folder.constructTransientObjectContainer(self, id='GarbageCollector', 
timeout_mins=10, 
limit=0, 
delNotification=BASEFOLDER+'DeleteTempImage')


and I get the following error:

Traceback (innermost last): Module 
ZPublisher.Publish, line 115, in publish Module ZPublisher.mapply, 
line 88, in mapply Module ZPublisher.Publish, line 41, in 
call_object Module OFS.DTMLMethod, line 144, in 
__call__ - DTMLMethod at /Coz/WUI/tst - 
URL: http://192.168.123.2:8080/Coz/WUI/tst/manage_main - 
Physical Path: /Coz/WUI/tst Module DocumentTemplate.DT_String, line 
476, in __call__ Module DocumentTemplate.DT_Let, line 75, in 
render Module DocumentTemplate.DT_Util, line 196, in 
eval - __traceback_info__: document_id Module 
string, line 1, in _expression_ Module 
Products.ExternalMethod.ExternalMethod, line 232, in __call__ - 
__traceback_info__: (('tst',), {}, None) Module 
/apps/zope/Extensions/cozumo.py, line 212, in ProcessControl Module 
string, line 1, in ? Module /apps/zope/Extensions/cozumo.py, 
line 219, in subtst Module /apps/zope/Extensions/cozumo.py, line 2473, 
in BuildGarbageCollectorAttributeError: 
constructTransientObjectContainer

 
If I change the external method as follows (remove the 
reference to 'folder'):
 
constructTransientObjectContainer(self, id='GarbageCollector', timeout_mins=10, 
limit=0, 
delNotification=BASEFOLDER+'DeleteTempImage')
There is no error, but the TOC is created in the wrong 
folder. I can manually (thru the ZMI) add a TOC to the TempImages folder, 
but I can't create one programmatically.

Can anyone point me in the right direction?!

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