[Zope-dev] post publishing hook

Florent Guillaume fg at nuxeo.com
Fri Apr 1 11:06:06 EST 2005


Chris McDonough  <chrism at plope.com> wrote:
> When do you think it should be called?

I should have answered that clearly:

I'd put it in ZPublisher.publish, like this:


        result=mapply(object, request.args, request,
                      call_object,1,
                      missing_name,
                      dont_publish_class,
                      request, bind=1)

        # INSERT HOOK CALL HERE

        if result is not response:
            response.setBody(result)

        # OR MAYBE HERE but above is probably better

        if transactions_manager:
            transactions_manager.commit()

Florent


> I just had to override
> zpublisher_validated_hook to do some stuff that would have been a bit
> easier if a different hook existed, but that might be a different use
> case...
> 
> 
> On Fri, 2005-04-01 at 10:48, Florent Guillaume wrote:
> > I really could use a post publishing hook.
> > Standard use case: delay indexing at the end of the request to only do 
> > it once per object even if the object has been modified 4 times.
> > 
> > Today there's the REQUEST._hold() hack with an instance having a 
> > __del__, but this gets executed outside the main transaction, and 
> > REQUEST is already dying.
> > 
> > I'd like a post-publishing hook that's called in the initial REQUEST and 
> > transaction.
> > 
> > Open issues are:
> > 1. what if there's an exception in the hook? I'd say log it but that's all.
> > 2. what if there's a Conflicterror? That's tougher to deal with... The 
> > transaction has to be retried, without the user being aware of it, so it 
> > means the hook should probably be called *before* things are sent to the 
> > browser.
> > 
> > What do you think?
> > 
> > Florent
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope )
> 


-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the Zope-Dev mailing list