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

2005-04-03 Thread Florent Guillaume
Dieter Maurer  [EMAIL PROTECTED] wrote:
 Christian Heimes wrote at 2005-4-1 22:28 +0200:
  ...
 You want to bind some actions to the transaction system because you want 
 to execute some code at the end of the first phase of the 2 phase 
 commit.
 
 I do not think that Florent wants to execute things at the end
 or in the first commit phase. Instead, he wants to execute something
 *BEFORE* this phase.

Yes, wherever it's inserted, I want to do additional processing before
everything is finalized, and in some cases I want to be able to abort
the transaction, and to create and change objects in the ZODB.

 Hooking into the transaction machinery of ZODB is very easy. Write 
 your own DateManager implementing the IDateManager interface and 
 register it into the current transaction using get_transaction.register(DM).
 
 For your use case overwrite the tpc_vote() method of the data manager to 
 do the indexing at the boundary between the two phases.
 
 This will not work for Florent's use case,
 at least not in the current ZODB (for Zope 2.7).
 
 Reason:
 
   The transaction freezes the set of objects it processes
   in the commit *BEFORE* the first commit phase.
 
   Therefore, no tpc_vote is allowed to modify any persistent
   object. Failure to do so leads to extremely nasty
   persistency errors (the object is marked changed but
   no transaction knows about it -- no change to this object in the future
   will get persisted until a restart).

Ah, that was what I was afraid of, but I was assured it was not the
case. I'll have to reread that transaction code... and maybe readd the
low-tech post-publishing hook I was thinking of.

Thanks Dieter,

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] Re: post publishing hook

2005-04-03 Thread Julien Anguenot
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

Dieter Maurer wrote:
 Christian Heimes wrote at 2005-4-1 22:28 +0200:
 
...
You want to bind some actions to the transaction system because you want 
to execute some code at the end of the first phase of the 2 phase 
commit.
 
 
 I do not think that Florent wants to execute things at the end
 or in the first commit phase. Instead, he wants to execute something
 *BEFORE* this phase.


That was the initial idea in our case.

 
Hooking into the transaction machinery of ZODB is very easy. Write 
your own DateManager implementing the IDateManager interface and 
register it into the current transaction using get_transaction.register(DM).

For your use case overwrite the tpc_vote() method of the data manager to 
do the indexing at the boundary between the two phases.
 
 
 This will not work for Florent's use case,
 at least not in the current ZODB (for Zope 2.7).
 
 Reason:
 
   The transaction freezes the set of objects it processes
   in the commit *BEFORE* the first commit phase.
 
   Therefore, no tpc_vote is allowed to modify any persistent
   object. Failure to do so leads to extremely nasty
   persistency errors (the object is marked changed but
   no transaction knows about it -- no change to this object in the future
   will get persisted until a restart).
 
 

I've been implementing a IndexationManager hook doing the job for CPS
but I get the error your talking about...

Thanks Dieter for the explanation. Your mail just arrived when I was
trying to understand the persistency problems :(

I got POSKeyError, Unauthorized (at catalog level while indexing and
trying to get object attributs) or KeyError (Connection.setState())
exceptions randomly as well.

Is there a way to hook before the first transaction commit phase ?

J.

- --
Julien Anguenot | Nuxeo RD (Paris, France)
CPS Plateform : http://www.cps-project.org
mail: anguenot at nuxeo.com; tel: +33 (0) 6 72 57 57 66
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFCUFReGhoG8MxZ/pIRAi2jAJ4hXTAJhqJB8czSkQpVCCBEKzWXtACfXA/m
S4JfeBF+TWweLWPSoxobPEE=
=8zPL
-END PGP SIGNATURE-
___
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] Re: post publishing hook

2005-04-01 Thread Florent Guillaume
Christian Heimes  [EMAIL PROTECTED] 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.
 
 Using a post publishing hook for this use case isn't a good idea - IMO. 
 The Publisher has nothing to with indexing. It's a completly different 
 part of the architecture.
 
 You want to bind some actions to the transaction system because you want 
 to execute some code at the end of the first phase of the 2 phase 
 commit. That's a completly different story than the post publishing 
 hook. Hooking into the transaction machinery of ZODB is very easy. Write 
 your own DateManager implementing the IDateManager interface and 
 register it into the current transaction using get_transaction.register(DM).
[note: s/IDateManager/IDataManager/ above]
 
 For your use case overwrite the tpc_vote() method of the data manager to 
 do the indexing at the boundary between the two phases.
 
 Jens Vagenpohl's mail host and Chris McD's blob have example code for you.

Ok, Tres also recommended something like that.

I was a bit concerned that there would be problems in case of conflicts,
or if there was a need to tweak the body returned to the user, but after
reading transaction's code and MailDropHost and re-re-reading
Publisher.py, I'm confident I can do everything I need.

Thanks a lot, this together with events will make things much easier in
our framework.

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 )