[Zope] List editing with page templates
Dieter Maurer
dieter@handshake.de
Sat, 30 Mar 2002 21:44:28 +0100
Richard Wesley writes:
> I need to create a form (using page templates) that does roughly this:
>
> <BasicData>
>
> <selectable list of homogenous objects to attach to BasicData>
>
> <list of homogenous objects already attached to BasicData>
>
> The problem is that I can't seem to make the attached list
> persistent. In my action script for attaching a new list object, I
> check the request to see if the list is present and append the
> selected object to the attached object list, but the script never
> seems to have access to the request passed to the form.
Please read the "Web publishing" section of
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
You will find that "REQUEST" is what the name suggests (oh wonder!):
a description of a single, the current, request: no memory for
earlier requests.
When you need such a memory, you are looking for a session.
Zope 2.5 comes with an integrated session product.
It's very easy to use:
SESSION.set(key,value)
sets "key" to "value" in one request and
SESSION[key]
retrieves it in later requests.
An alternative is to code the list in a sequence of hidden variables:
<input type="hidden" name="myList:list" value="val1">
<input type="hidden" name="myList:list" value="val2">
....
Needless to say, that this is much more work...
Dieter