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

Negroup - negroup at gmail.com
Tue Jul 5 05:05:03 EDT 2005


2005/7/5, Tino Wildenhain <tino at wildenhain.de>:
[cut]

> So best option I see is to not pass the object but rather
> pass the reference to the object. You can resolve
> it via restrictedTraverse('/path/from/form')

I think I can't apply your solution. restrictedTraverse asks for a
path, and then it supposes that the object is stored inside ZODB. This
is not my case. Let me provide a minimanl explaination about how my
application is structured.

1. A user can uploads a zipped file via HTML form in "upload_zip" ZPT.
The action of the form points to check_zip, an External Method that
checks for validity of each file inside the archive.

2. check_zip returns to upload_zip a tuple containing two elements:
True or False (based on the correctness of archive) and the object
itself, via self parameter.

3. after the external method has been called, upload_zip shows other 2
forms that the user will use to abort operation or to continue the
process. The form to continue will pass the object to another external
method in order to compute the result. This is the step where I
encounter the problem, I can't pass object.

This should explain why I haven't the object stored inside ZODB.

Probably the solution would be to store the uploaded object inside a
temporary area of ZODB and then I'll be able to do all the tasks I
need.

Any further consideration/hints?

Thanks

> Btw. avoid much code in the Template. Its a maintenance
> headache. You can do it esily in a python script and
> call this from template.

Yes, once found the way to follow, spread the code between dedicated
objects will be pure amusement ;-)


More information about the Zope mailing list