Hello, stupid question, but... I want to redirect to register.zpt. How can I do that? RESPONSE.redirect = context.register.zpt.absolute_url Thanks, Florian
you could try: RESPONSE.redirect( context['register.zpt'].absolute_url() )
-----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org]On Behalf Of Florian Lindner Sent: Thursday, October 02, 2003 12:24 PM To: zope@zope.org Subject: [Zope] Calling objects with a dot in them
Hello, stupid question, but...
I want to redirect to register.zpt. How can I do that?
RESPONSE.redirect = context.register.zpt.absolute_url
Thanks, Florian
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Douwe Osinga wrote:
you could try:
RESPONSE.redirect( context['register.zpt'].absolute_url() )
Ok, thanks. It works. Another question: ;-) 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.. Thanks, Florian
-----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org]On Behalf Of Florian Lindner Sent: Thursday, October 02, 2003 12:24 PM To: zope@zope.org Subject: [Zope] Calling objects with a dot in them
Hello, stupid question, but...
I want to redirect to register.zpt. How can I do that?
RESPONSE.redirect = context.register.zpt.absolute_url
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. You may want to check error types if you do anything more complex than checking a REQUEST parameter. Check the online help for details on that. --jcc -- "Code generators follow the 80/20 rule. They solve most of the problems, but not all of the problems. There are always features and edge cases that will need hand-coding. Even if code generation could build 100 percent of the application, there will still be an endless supply of boring meetings about feature design." (http://www.devx.com/java/editorial/15511)
J Cameron Cooper wrote:
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? Thanks, Florian
You may want to check error types if you do anything more complex than checking a REQUEST parameter. Check the online help for details on that.
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
participants (3)
-
Douwe Osinga -
Florian Lindner -
J Cameron Cooper