[Zope] publish() hook

Dieter Maurer dieter@handshake.de
Tue, 23 Apr 2002 21:58:30 +0200


Stadtverwaltung Schwarzenberg writes:
 > I'd like to add a little functionality to my ZPublisher.Publish.publish
 > method. So I created a new Product and in the __init__.py file of ths
 > product I put code like this:
 > 
 > import ZPublisher
 > 
 > def publish_new(same fingerprint as ZPublisher.Publish.publish):
 >     response = ZPublisher.Publish.publish_old(paramaters)
 >     #
 >     #aditional functionality
 >     #
 >     return respone
 > 
 > ZPublisher.Publish.publish_old = ZPublisher.Publish.publish
 > ZPublisher.Publish.publish = publish_new
 > 
 > Using this code Zope starts up w/o error but I don't see any effects of my
 > new publish method. In fact - even if there is an error in my additional
 > code it never raises an exception so I figure that my new pubish method
 > never gets called.
 > 
 > Some additional info: I'm running Zope 2.4.1 on a WinNT machine.
 > 
 > Can anyone help me out? Please?
The "user" probably does

    from ZPublisher.Publish import publish

Then, later changes to "ZPublisher.Publish" do not affect the imported
"publish".

If that's the reason, you need to find the "publish" and change it
there, too.


Dieter