This dtml fragment fails strangely --- <dtml-var standard_header_html> <dtml-if expr=pythonscript()> <dtml-call expr="REQUEST['RESPONSE'].redirect('index_html')"> <dtml-else> <dtml-call expr="REQUEST['RESPONSE'].redirect('originalform?'+marshallformvars())"> </dtml-if> <dtml-var standard_footer_html> The pythonscript() validates the form variables. marshallformvars() is a python script that returns the appropriately quoted name/value pairs. The observed behavior is strange. If the pythonscript() returns 0, the transfer to the originalform occurs along with the diagnostic information inserted by the validation script. This is the behavior I expect. But when the pythonscript() returns 1, I get a Zope error indicating that the sytem cannot find, not index_html but /aaa/bbb/ccc/ddd/%3A Both the index_html and the failing dtml-method are in the folder referenced via the path /aaa/bbb/ccc/ddd. As a workaround I replaced the first redirect with a <dtml-var index_html> but I do wonder why the initial approach failed. Insight appreciated. -dra
I can't say specifically, but %3A is ':', so I'd guess marshaformvars() is returning something with a ':' in it, which might confuse the browser. Try URL encoding that part. FWIW, using the standard headers and footers is a waste of time here, since redirect is part of the HTTP headers which appears before any HTML.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Dennis Allison Sent: Sunday, August 25, 2002 9:46 PM To: zope@zope.org Subject: [Zope] redirect strangeness ...
This dtml fragment fails strangely ---
<dtml-var standard_header_html> <dtml-if expr=pythonscript()> <dtml-call expr="REQUEST['RESPONSE'].redirect('index_html')"> <dtml-else> <dtml-call expr="REQUEST['RESPONSE'].redirect('originalform?'+marshallformvars())"> </dtml-if> <dtml-var standard_footer_html>
The pythonscript() validates the form variables. marshallformvars() is a python script that returns the appropriately quoted name/value pairs.
The observed behavior is strange. If the pythonscript() returns 0, the transfer to the originalform occurs along with the diagnostic information inserted by the validation script. This is the behavior I expect.
But when the pythonscript() returns 1, I get a Zope error indicating that the sytem cannot find, not index_html but
/aaa/bbb/ccc/ddd/%3A
Both the index_html and the failing dtml-method are in the folder referenced via the path /aaa/bbb/ccc/ddd.
As a workaround I replaced the first redirect with a <dtml-var index_html> but I do wonder why the initial approach failed. Insight appreciated.
-dra
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Dennis Allison wrote:
This dtml fragment fails strangely ---
<dtml-var standard_header_html> <dtml-if expr=pythonscript()> <dtml-call expr="REQUEST['RESPONSE'].redirect('index_html')"> <dtml-else> <dtml-call expr="REQUEST['RESPONSE'].redirect('originalform?'+marshallformvars())"> </dtml-if> <dtml-var standard_footer_html>
The pythonscript() validates the form variables. marshallformvars() is a python script that returns the appropriately quoted name/value pairs.
The observed behavior is strange. If the pythonscript() returns 0, the transfer to the originalform occurs along with the diagnostic information inserted by the validation script. This is the behavior I expect.
But when the pythonscript() returns 1, I get a Zope error indicating that the sytem cannot find, not index_html but
/aaa/bbb/ccc/ddd/%3A
Both the index_html and the failing dtml-method are in the folder referenced via the path /aaa/bbb/ccc/ddd.
As a workaround I replaced the first redirect with a <dtml-var index_html> but I do wonder why the initial approach failed. Insight appreciated.
To debug this problem, you might want to use the nice tcpwatch (-> google). It acts as a proxy but displays the complete http conversation in a window. Another remark to your redirects, AFAIK the the rfc mandates to redirect to complete URLs, not just the relative link. I don't know offhand if zope "fixes" you redirect, but I would use something like absolute_url()+'/index_html' as a target instead. cheers, oliver
Dennis Allison writes:
This dtml fragment fails strangely ---
<dtml-var standard_header_html> <dtml-if expr=pythonscript()> This would give you a KeyError "pythonscript()". Please be more careful, when reporting problems...
... But when the pythonscript() returns 1, I get a Zope error indicating that the sytem cannot find, not index_html but
/aaa/bbb/ccc/ddd/%3A Check the "ZServer" log file ("var/Z2.log").
For a redirect, you should see a "302" reponse code with the redirect location in the after next column. There, you can check, whether the redirect location was generated wrongly or whether the error happens in the redirect request (which often occurs). Dieter
participants (4)
-
Charlie Reiman -
Dennis Allison -
Dieter Maurer -
Oliver Bleutgen