objects in scope of REQUEST
Hi again everyone, I'd like my Product to be able to create certain objects on-demand, but only once per REQUEST. If via DTML or PythonScript etc ask for the same object more than once during the REQUEST, my Product won't create an additional instance. But most importantly, I need to make sure that these objects get destroyed when the REQUEST is done - so I don't leave a bunch of objects hanging around forever. Is this possible? I've seen somewhere that Temporary Folder can do this, but it looks as if that holds onto objects until Zope is shutdown - not what I'm looking for. Thanks for any hints, advice, or pointers to where to look for more info. btw - is anyone else out there timing out trying to hit zope.org? I can't even get cached pages from google. Jim
objects in scope of REQUEST <snip> From: Jim Abramson I'd like my Product to be able to create certain objects on-demand, but only once per REQUEST. If via DTML or PythonScript etc ask for the same object more than once during the REQUEST, my Product won't create an additional instance. </snip> </snip> By "once per REQUEST" I am assuming that what you are looking for is to have the end-user enter some information via an html form and then only have zope process that information once. A couple of possible solutions: 1) use javascript to control form submission (ie. only let the user submit the form once) 2) create the form with a 'hidden' field that contains a unique id. When you process that id (via a zope method), save the id. If the same id is submitted a second time ignore it (ie. the user is trying to resubmit the form) <snip> But most importantly, I need to make sure that these objects get destroyed when the REQUEST is done - so I don't leave a bunch of objects hanging around forever. Is this possible? I've seen somewhere that Temporary Folder can do this, but it looks as if that holds onto objects until Zope is shutdown - not what I'm looking for. </snip> If you don't want the object saved after you have finished the user's request then don't create an object that is persisted (ie stored) in the zodb. An example: user enters some info on an html form and submits it; you process that info via a dtml method (or script or external method or...) and generate an html response (ie. your method creates a sequence of html tags, etc) and then displays them to the user. You are not creating any kind of document, file, etc which could be stored. <snip> btw - is anyone else out there timing out trying to hit zope.org? I can't even get cached pages from google. </snip> zope.org is down for maintenance. It should be back up today. This should not affect google's cached pages though. HTH Jonathan
participants (2)
-
Jim Abramson -
Jonathan Hobbs