durusmail: quixote-users: Redirect in start_request
Redirect in start_request
2004-08-16
2004-08-18
Redirect in start_request
Thomas Guettler
2004-08-18
Am Montag, 16. August 2004 17:12 schrieb Thomas Guettler:
> Hi,
>
> What is the best way to redirect or return a special page
> in start_request?

Since nobody had an idea, I do it like this:

class DummyRootNamespace:
    _q_exports=[]

    def __init__(self, redirect_target):
        self.redirect_target=redirect_target

    def _q_lookup(self, request, component):
        return self

    def __call__(self, request):
        request.redirect(self.redirect_target)
        return ""

in start_request:
        if ...:
            target="...?OLDURL=%s" % (urllib.quote_plus(
                request.environ["REQUEST_URI"]))
            self.root_namespace=DummyRootNamespace(target)
            return

I think it is too complicated.

Regards,
 Thomas


reply