[Zope] Avoiding page redirects from TAL

Analog Kid garlictrompet at gmail.com
Mon Mar 9 23:35:40 EDT 2009


Hi All:

I have a customized page template product which subclasses from
ZopePageTemplate. In this product class, I have a method that redirects to a
certain fixed page that I have created in the ZMI. One of the objects of
this type makes calls to this method and also has some conditional redirects
(based on certain request variables). Here is a representation

In my Product class, I have a method which conditionally redirects ...

def check_and_redirect(self):
    request = self.REQUEST
    if request.get('redirect_to_fixed_page', False):
        request.RESPONSE.redirect('http://somefixedurl_in_my_domain')

def getValue(self):
    self.check_and_redirect()
    # do some more stuff
    ....
    ....
    return 'some value'

My ZPT looks like this ...
...
<tal:call tal:define="data python:mytemplate.getValue()"/>
...
...
...
...
<tal:redir tal:condition="python:here.REQUEST.has_key('var')">
<tal:dummy tal:define="test python:here.REQUEST.RESPONSE.redirect('
http://someotherurl")"/>
</tal:redir>
...
...
...


What is happeninig is that the redirect in the PT is taking precedence over
my redirect (which Im doing in the method). My question is: Can I make sure
that my redirect takes precedence without modifying the PT itself. Is there
any other ZopePageTemplate method which I can patch so that my own redirect
kicks in first??

Thanks for you time and help.

-AK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20090310/849c1e0e/attachment.html 


More information about the Zope mailing list