Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

Redirecting from inside a TAL macro ...

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


garlictrompet at gmail

May 19, 2009, 6:27 AM

Post #1 of 3 (686 views)
Permalink
Redirecting from inside a TAL macro ...

Hi All:

I have a macro that is used in several other page templates. In some
circumstances, I need to redirect to another URL. Can I do this using
python:here.REQUEST.RESPONSE.redirect(<NEWURL>) so that the master page that
uses this macro is redirected to the NEWURL?

Regards,
G


lists at zopyx

May 19, 2009, 6:57 AM

Post #2 of 3 (631 views)
Permalink
Re: Redirecting from inside a TAL macro ... [In reply to]

On 19.05.09 15:27, Analog Kid wrote:
> Hi All:
>
> I have a macro that is used in several other page templates. In some
> circumstances, I need to redirect to another URL. Can I do this using
> python:here.REQUEST.RESPONSE.redirect(<NEWURL>) so that the master
> page that uses this macro is redirected to the NEWURL?

This is bad-style. Redirections belong into a browser view or a
PythonScript but
not into a page template and definitely not into a macro.

Andreas
Attachments: lists.vcf (0.31 KB)


tseaver at palladion

May 20, 2009, 6:46 AM

Post #3 of 3 (623 views)
Permalink
Re: Redirecting from inside a TAL macro ... [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andreas Jung wrote:
> On 19.05.09 15:27, Analog Kid wrote:
>> Hi All:
>>
>> I have a macro that is used in several other page templates. In some
>> circumstances, I need to redirect to another URL. Can I do this using
>> python:here.REQUEST.RESPONSE.redirect(<NEWURL>) so that the master
>> page that uses this macro is redirected to the NEWURL?
>
> This is bad-style. Redirections belong into a browser view or a
> PythonScript but
> not into a page template and definitely not into a macro.

To answer the OPs question: it *is* possible to do what you describe,
typically via a 'tal:define', e.g.::

<div tal:define="response request/RESPONSE;
should_redirect python:....;
dummy python:should_redirect
and response.redirect('...');">

Most long-time Zope folks frown on putting such logic in the template /
macro, because maintaining those templates gets pretty messy.


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver[at]palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKFAnG+gerLs4ltQ4RAlVCAJ9ly268z+bd0P+OY9a8KPIZKjdbGwCdEpyG
T9OL+s8+pH41U2A2zxnqfrg=
=2Jpw
-----END PGP SIGNATURE-----

_______________________________________________
Zope maillist - Zope[at]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 )

Zope users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.