[Zope] Refresh Page Template

Vital Lobachevsky tick at web.vi
Wed Apr 21 17:15:52 EDT 2004


Marco Mans wrote:
> Hi!
> 
> I've got a webform on a page-template. When the user clicks 
> on the submit button a python-script is called. After executing
> the script I want to refresh the page-template with the form on it.
> 
> I now use context.REQUEST.RESPONSE.redirect('name/of/pt') at the end
> Of the script. But (for example) when I call the script from another 
> page-template I also get redirected to the first pt...
> 
> I know, I could send a variable with the script-call and redirect to 
> the right pt, but I was wondering if there is another (better) way 
> of doeing this. For example if I could send a 'refresh' command to
> the browser!

I use special "handler" to process form actions. We need Page Template file 
(index.pt) and Python Script (formHandler).

index.pt looks like this:

<html>
...

<tal:block replace="structure here/formHandler" />

<form action="" method="post">
...
<input type="submit" name="action1" value=" Action1 " />
<input type="submit" name="action2" value=" Action2 " />
</form>
</html>


formHandler at least contains handlers for each action:

...

if hasattr(request, 'action1'):
     do_something()

elif hasattr(request, 'action2'):
     call_other_script()


It's basis. I made very complex things around this: set/change request 
variables, validation, error messages, etc.


Cheers,
Vital Lobachevsky
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3146 bytes
Desc: S/MIME Cryptographic Signature
Url : http://mail.zope.org/pipermail/zope/attachments/20040422/62cb4bf2/smime.bin


More information about the Zope mailing list