Re: [Zope-dev] post publishing hook

2005-04-04 Thread Jim Fulton
Florent Guillaume wrote:
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.
I'd rather not take the time to discuss this now, since we
seem to be on track with the transaction idea, which I still think
is a better fit.
If you really want to discuss this now, I'll respond, although
maybe not today. :)
Jim
--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
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 R&D
+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-04 Thread Jim Fulton
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.
2. A pre-commit hook.  I think your use case fits this much better.
   We've thought about this for some time. In fact, I've talked about
   it enough that I thought we already had this, but we don't.
   I think this is the way to go for your use case.
   I'll post a proposal on the zodb-dev list.
Jim
--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
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 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
Christian Theune wrote:
Florent Guillaume:
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.
Are your talking about a short thing for 2.7?
Yes we need it for CPS which currently works with 2.7 (no customer is 
ready to move to 2.8 yet).

In 2.8 I wonder if the
Publisher could start using e.g. Zope 3 events. Are there events for
this around in Z3 already? This would be a good way of improving
transition to Z3 in a compatible manner, if both systems e.g. publisher
modules would spit out the same events for handling those cases.
Yes events are the way to go. For 2.7 we have our (CPS) event system, 
and Julien has experimented with patching Transaction.py's commit and 
abort to send appropriate events. Then the rest is just a matter of 
subscribing and reacting to them.

I totally agree that if 2.8 could use standardized events from Zope 3 
that would be awesome.

Florent
--
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+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-04 Thread Christian Theune
Hi,

Are your talking about a short thing for 2.7? In 2.8 I wonder if the
Publisher could start using e.g. Zope 3 events. Are there events for
this around in Z3 already? This would be a good way of improving
transition to Z3 in a compatible manner, if both systems e.g. publisher
modules would spit out the same events for handling those cases.

Am Freitag, den 01.04.2005, 17:48 +0200 schrieb Florent Guillaume:
> 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.

Christian

-- 
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-01 Thread Dieter Maurer
Florent Guillaume wrote at 2005-4-1 17:48 +0200:
> ...
>Open issues are:
>1. what if there's an exception in the hook? I'd say log it but that's all.

I prefer: fail in the usual way.

>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.

As you do it in the same transaction, you usually do it
before anything is sent to the browser (unless someone
uses "RESPONSE.write").

I would handle the post publishing hook identical to
the main request action.

-- 
Dieter
___
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 R&D
+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 Florent Guillaume
I didn't know about that hook, but from reading the code it seems it 
takes place before publishing, not after.

There's the recent post_traverse hook too, but that's not what I want.
Florent
Chris McDonough wrote:
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


--
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of R&D
+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] 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] 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 )


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 )