Re: [Zope-dev] post publishing hook

2005-04-04 Thread Christian Theune
Am Montag, den 04.04.2005, 13:39 +0200 schrieb Florent Guillaume:
 Yes we need it for CPS which currently works with 2.7 (no customer is 
 ready to move to 2.8 yet).

Neither is 2.8. ;)

-- 
gocept gmbh  co. kg - schalaunische str. 6 - 06366 koethen - germany
www.gocept.com - [EMAIL PROTECTED] - phone +49 3496 30 99 112 -
fax +49 3496 30 99 118 - zope and plone consulting and development


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
___
Zope-Dev maillist  -  Zope-Dev@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 )


Re: [Zope-dev] post publishing hook

2005-04-04 Thread Florent Guillaume
Jim Fulton wrote:
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.
I haven't been folowing this thread, so I asked Gary what it was about. :)
Based on that, I'd like to suggest:
There are two possibilities:
1. A post publishing hook.  I think this would be appropriate
   in the case where you really want to augment the publishing
   process.  For example, I hpe someday to use something like
   this to provide another way (other than metal) to provide
   standard look and feel.
   Unfortunately, I think there are a lot of open issues, at least
   in my mind, about how something like this should work.
What I had in mind was, just after Publish.publish calls
result = mapply(object, request.args, request, ...)
add:
if hasattr(request, 'runPostPublishingHooks'):
result = request.runPostPublishingHooks(result, request, 
response)

And a simple system for registering hooks.
Florent
--
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope-Dev maillist  -  Zope-Dev@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 )


Re: [Zope-dev] post publishing hook

2005-04-01 Thread Chris McDonough
When do you think it should be called?  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@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 )


Re: [Zope-dev] post publishing hook

2005-04-01 Thread Florent Guillaume
Chris McDonough  [EMAIL PROTECTED] 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@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 RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope-Dev maillist  -  Zope-Dev@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 )


Re: [Zope] Re: [Zope-dev] post-publishing hook

2002-12-12 Thread Florent Guillaume
Shane Hathaway  [EMAIL PROTECTED] wrote:
 On 11/29/2002 01:33 PM, Ivo van der Wijk wrote:
 
  On Fri, Nov 29, 2002 at 01:07:24PM +0100, Carlo Giomini wrote:
 
  Dear all,
  I need a sort of post-publishing hook (so to say). I need Zope to call a
  function of mine as the very last action of publishing a request, 
  i.e. after
  having built the response (and sent it to the browser possibly), but
  before starting publishing a new request. My Zope server is running as a
  single-threaded app.
  Does Zope support this any way?
 
  You'll be working outside the REQUEST transaction at that moment, so 
  please
  keep that in mind when modifying objects.
 
 In fact, the database connection might already be closed.  If you need 
 to read or write the ZODB, you might have to open a private connection 
 and close it before returning.  Ugh.

Indeed, the connection has already been closed at that point so you will
need to open a new one. Note also that you won't be able to report any
error to the user (obviously).

Florent
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] post-publishing hook

2002-11-29 Thread Ivo van der Wijk
On Fri, Nov 29, 2002 at 01:07:24PM +0100, Carlo Giomini wrote:
 Dear all,
 I need a sort of post-publishing hook (so to say). I need Zope to call a
 function of mine as the very last action of publishing a request, i.e. after
 having built the response (and sent it to the browser possibly), but
 before starting publishing a new request. My Zope server is running as a
 single-threaded app.
 Does Zope support this any way?
 

There is a way, but I find it somewhat ugly/hackish. But Shane uses it
in CookieCrumbler, so it must be good ;)

You can pass an instance to REQUEST._hold, which should be deleted 
when REQUEST gets deleted, so at the complete end of the request.

This means you can pass an instance to a class that defines a __del__
method, where you can do your work.

You'll be working outside the REQUEST transaction at that moment, so please
keep that in mind when modifying objects.

Cheers

Ivo

-- 
Drs. I.R. van der Wijk  -=-  
Brouwersgracht 132 Amaze Internet Services V.O.F.
1013 HA Amsterdam, NL   -=-  
T +31-20-4688336 F +31-20-4688337Linux/Web/Zope/SQL/MMBase   
W http://www.amaze.nlE [EMAIL PROTECTED] Network Solutions
W http://vanderwijk.info E [EMAIL PROTECTED] Consultancy  
PGP http://vanderwijk.info/pgp  -=-  

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope] Re: [Zope-dev] post-publishing hook

2002-11-29 Thread Shane Hathaway
On 11/29/2002 01:33 PM, Ivo van der Wijk wrote:


On Fri, Nov 29, 2002 at 01:07:24PM +0100, Carlo Giomini wrote:

Dear all,
I need a sort of post-publishing hook (so to say). I need Zope to call a
function of mine as the very last action of publishing a request, 
i.e. after
having built the response (and sent it to the browser possibly), but
before starting publishing a new request. My Zope server is running as a
single-threaded app.
Does Zope support this any way?



There is a way, but I find it somewhat ugly/hackish. But Shane uses it
in CookieCrumbler, so it must be good ;)

Reliable and good are not necessarily the same thing. :-)  Since the 
only way ZODB connections ever get closed in a standard Zope setup is 
through the request.hold() mechanism, you can be sure that if Zope is 
working at all, the side effects of request.hold() are working.  Relying 
on side effects can be dangerous, though.

You'll be working outside the REQUEST transaction at that moment, so 
please
keep that in mind when modifying objects.

In fact, the database connection might already be closed.  If you need 
to read or write the ZODB, you might have to open a private connection 
and close it before returning.  Ugh.

Shane


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope )