I add a ErrCode variable to register.zpt. So in fact it redirects to "http://example.com/register.zpt?ErrCode=nouser". Now I want to add some HTML Code to the register.zpt with ZPT if ErrCode has the value "nouser". The problem is that ErrCode is not given in all cases. How can I do that? I suppose something with tal:condition but I don't really know how..
One way might be:
<span tal:condition="python:request['ErrCode']=='nouser'" tal:on-error="nothing">A!</span>
The span, of course, can be any tag, or go away with a tal:omit-tag.
Thats about that what I do. I first define assign a variable:
tal:define="ErrCode REQUEST/ErrCode|string:'noerror'"
And then test with:
<font size="-1" color="red" tal:condition="python: ErrCode=='noname'">A!!</font>
But the A! is always there, even if no ErrCode is provided. What's wrong?
Took me a moment to figure it out, but it's really dead obvious, as you would have seen had you tried the define without the string fallback. There is no such thing as 'REQUEST'. The built-in name for the request object in a TALES expression is 'request'. As in lower case. Use that instead and it works fine. --jcc