Ian Bicking: the old part of his blog


You have to be careful in Zope when redirecting and using sessions.

If you raise the string 'Redirect' (capital R), it will cause Zope to abort the transaction and thus, abort the session write. There are cases when this is what you want - going along, coming across a problem after some data has already been written, and wanting to alert the user to this fact.

When you use the redirect method on Zope's RESPONSE object, the transaction will commit and the session data will be retained.

In cases like this, I've started using my own API calls such as 'returnWithMessage' which takes, among other parameters, a 'do_raise' argument. If 'do_raise' is true, the Redirect is raised as an error. If false, a regular redirect occurs. I've just added smarts into one of those calls to use a new 'page_messenger' service I wrote, inspired by your post (it's a bit cleaner than calling request.SESSION.set in a template, and has let me retain expections from current code that passes the message in via the request or a template call option).
Comment on Web Application Patterns: Status Notification
by Jeffrey Shell