[ZPatterns] Announce: TransactionAgents 0.0.1

Steve Alexander [email protected]
Thu, 26 Jul 2001 19:24:07 +0100


Hi folks,

Please forgive the cross-posting.
The discussion of Transactions and ZODB has spilled over a number of 
mailing lists. Just be thankful I'm not copying in the cmf list!

Here's what I've been working on recently:

   http://www.cat-box.net/steve/TransactionAgents-0.0.1.tar.gz

Inside the archive file are three products. I'm using all three, and 
they work for me. You'll need Python 2.1 and Zope 2.4.

As usual, here's a warning:

   Do not use this stuff on important systems.
   Do not rely on the API staying the same.
   Do not rely on any of this finding its way
   into ZPatterns or Zope or ZODB.


The products are as follows:

PlugIns:

   Exactly what I found just now in CVS at eby-sarna.com

ZPatterns:

   I took exactly what I found just now in CVS at eby-sarna.com,
   fixed one showstopper bug (see my message to the ZPatterns list)
   made a few changes for it to play nicely with Zope 2.4,
   and altered the parts of ZPatterns that use transactions to
   use the TransactionAgents product.
   For kicks, the version.txt of this release is
     ZedPatterns-0-4-3p2-transactionagents

TransactionAgents:

   A runtime patch to ZODB.Transaction.Transaction to implement four
   types of Agent.

   1: The Rule Agent. Runs on a commit

   2: The Indexing Agent. Runs on a commit, after the Rule Agents
      are done. (*)

   3: The Boundary Agent. Runs when the outermost transaction is
      done (either aborted or commited).

   4: The Post-Commit Agent. Runs in its own transaction after
      the outer transaction is successfully committed.

(*) Things get interesting when you commit a subtransaction from a rule 
agent or an indexing agent. It works; see the test suite for an example 
of what happens it works.

An important thing is that exceptions in Rule Agents and Indexing Agents 
  are not caught, but propagate just like they would in normal methods.
Exceptions raised in Boundary Agents and Post Commit Agents get 
swallowed and ignored (except for a warning to the log).

This is important because running Rules and updating Indexes are usually 
  a vital part of the transactional logic of an application. (Someone 
please translate that into plain language!).

See also the test suite in the tests/ subdirectory. The comments and 
docstrings there should help to explain what is going on.

For ZPatterns enthusiasts, here's the release notes for 
ZedPatterns-0-4-3p2-transactionagents:

----
26 July 2001

Welcome to ZedPatterns-0-4-3p2-transactionagents.

This is an experimental and unofficial release of ZPatterns,
to test out new ideas, and clear a path to compatibility with
Zope 2.4 and Python 2.1.

I've included an unaltered copy of the PlugIns product, as it
is required by ZPatterns.

UnTar the contents of the archive directly in your Products
directory.

Changes from ZPatterns 0-4-3p2:

* SkinScript works with Zope 2.4.

* Fixed __set_attr__ bug involving _v_parent

* Requires Python 2.1, Zope 2.4.

* Requires TransactionAgents product.

* Agents now run just before transactions get commited
   rather than during a tpc_commit.

* New SkinScript for running a trigger as an IndexingAgent.
   It goes like this::

     WHEN OBJECT CHANGED INDEX CALLING expression

   Indexing agents run after normal agents/triggers (called
   Rule Agents), although there are special rules for
   when a subtransaction is committed while an agent is running.
   See the TransactionAgents product's test suite for details.


* ZPatterns doesn't go into an infinite loop if you commit
   a subtransaction from a trigger.

* Support for list comprehensions in SkinScript.

* Per-transaction cached _v_ attributes now last until the
   outermost transaction has finished. This will improve
   execution speed by a miniscule amount in some circumstances.

----

Credit where it's due... The ideas behind TransactionAgents were 
discussed by Phillip Eby and Shane Hathaway a couple of months ago on 
the Zope-Dev mailing list.
I used Casey Duncan's Hotfixes HowTo as a guide to writing the runtime 
patch.
I read up on test suites from Michel P and Chris McD's ZDG.
Phillip Eby and Ty Sarna came up with the original ZPatterns product, 
maintain the difinitive version of it, and are the ultimate arbiters of 
taste and decency as to what features and patches make it into a real 
ZPatterns release.

All bugs and mistakes in ZedPatterns and TransactionAgents are mine 
alone. Patches and feedback welcome.

--
Steve Alexander
Software Engineer
Cat-Box limited