[Zope] Re: Pass objects from template to template via HTML forms.

Malcolm Cleaton malcolm at jamkit.com
Tue Jul 5 08:23:45 EDT 2005


On Mon, 04 Jul 2005 22:53:58 +0200, Negroup - wrote:
> Is there some way to pass an object from template A to template B via
> HTML forms?
> 
> A
> <form name="a" action="b" method="post">
> <input type="hidden" name="obj" tal:attributes="value here" />
> <input type="submit" value="Press" />
> </form>
> 
> B
> <b tal:content="structure here/REQUEST"></b>
> 
> Template B prints:
> form
> obj	'<OrderedFolder instance at 42d9aec0>'
> 
> I need the object itself, not the string representing the object!

No can do I'm afraid.

The objects you deal with live only in the Zope server. When you send a
response back to a user, this is just HTML, made of strings. Based on
this, the user's browser sends back a new HTTP request, again made up of
strings.

When this new request arrives, Zope has forgotten the previous
response, apart from perhaps something in a user's session or in the ZODB
somewhere.

So, if you wish to keep track of an object during a sequence of requests
with the user, you must make arrangements to keep the object somewhere in
Zope, and to find it as each request comes in.

Common ways to cope in this situation include:

- Make do without an object at all; run everything with just strings until
you come to the end of the process and are ready to commit to the ZODB.

- Store an object in the user's session.

- Store an object in a temporary location in the ZODB, and pass around a
path to it in your various forms.

Hope this helps.

Thanks,
Malcolm.

-- 

    [] j a m k i t
      web solutions for charities

         malcolm cleaton
T:  020 7549 0520
F:  020 7490 1152
M:  07986 563852
W: www.jamkit.com




More information about the Zope mailing list