Short story :

response.status is not set when PubBeforeAbort and PubFailure events are 

Any code in the event handlers trying to use response.status always gets 
200 even though an exception has happened.

Longer story :

publish function in ZPublisher.Publish.py is notifiying all publication 
events ZPublisher.interfaces.IPubEvent.

It is called by publish_module_standard function which is in charge of 
transforming exceptions into HTTP status by calling response.exception().

However, this happens after the publishing events have been notified.

IOW, when failure events (PubBeforeAbort and PubFailure) are notified, 
request.status is still 200 :-(

Proposal attempt:

First, a disclaimer : there are so many nested try except, try finally 
in publish and publish_module_standard functions that I am sure I do not 
fully understand the code. However, I'll state my thoughts as a starting 

I have the feeling that moving the call to response.exception() into the 
publish function before the events are notified would break a lot of 
code. Maybe we could just move the setStatus() call made in 

We might move the notification of PubFailure to response.exception(). 
However, its semantics would then change slightly and it is not obvious 
which exc_info would then be passed to the event.

I'd appreciate feedback on this issue.
Godefroid Chapelle (aka __gotcha) http://bubblenet.be
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to