[Zope] [Ann] emulateRedirect: emulates redirection inside Zope

Dieter Maurer dieter@handshake.de
Tue, 1 May 2001 21:02:36 +0200


The common task:

     A user fills a form and submits it. The submitted data is checked
     and if problems are detected, the user gets its
     original form together with a problem indication
     *AND* his already filled in data.

is not yet well supported.

A redirection to the form suffers from browser differences
in the handling of the old request data and
the difficulty to add all of them into the redirected
URL.

Presenting the form without redirection is possible
but has several caveats:

  Side effects caused before the problem has been detected are
  difficult to discard.

  The 'base' used by the browser for URL resolution may
  become wrong, seriously confusing the browser and/or
  Zope.


The small External Method 'emulateRedirect' emulates
a redirect without an extra interaction with the browser.
It resets the REQUEST parameters such that they get
the same values as for a direct traversal to the
redirected object. Furthermore, it sets the
'base' tag used by the browser for resolution of
relative URL such that relative references from the
redirected to object become correct.
'emulateRedirect' provides control over the transaction
('abort', 'commit', 'keep').


'emulateRedirect' works for Zope 2.3. It may work with Zope 2.2.
As it uses undocumented Zope publishing features, it may
break with any new Zope version.


More information and download via:

  URL:http://www.dieter.handshake.de/pyprojects/zope




Dieter