[ZPatterns] Re: [Zope-CMF] Zope component model and CMF
Steve Alexander
[email protected]
Fri, 20 Jul 2001 09:39:14 +0100
Chris Withers wrote:
>
> IIUC, ZPatterns triggers are what you're trying to make the equivalent
> of. Steve
> Alexander had some good ideas how to get this to work at the Berlin
> Zope Conference.
>
> Steve?
I'm *almost* finished with a product for a runtime patch to
Transaction.py that implements triggers.
It works for me, but I need to tidy it up before releasing it.
This is more-or-less along the lines of what Phillip Eby and Shane
talked about on Zope-Dev a month ago or so, wrt RuleAgents,
IndexingAgents and queues of triggers running just before a transaction
commit.
I'll be releasing it tomorrow (tonight if I'm lucky), along with a
slightly forked simplified version of ZPatterns that uses the new hooks
in Transaction.py.
The patch works nicely with Subtransactions, even if they're commited
while a a Trigger is running. It also copes sensibly with triggers that
add other triggers.
I'll be recommending that people stay with "standard" ZPatterns for
important systems, but that they try this one if they need to use
subtransactions inside triggers, or they want better behaviour when
triggers raise exceptions.
I'll be using the Transactions patch on its own (without ZPatterns) on
some ZODB work I'm doing.
On its own, this change doesn't allow for transparent indexing. This
just allows you to register actions that will occur at transaction
boundaries.
You also need to add a setattr/delattr (or whatever) hook to objects
that you want transparently indexed. When an attribute changes, you
enqueue an Agent that will catalog the object. This runs at a
transaction boundary, just before the commit. This way, you only
recatalog at most once per transaction. It's nice for sending out
notifications too, again, at most once per transaction.
This nice thing is that a framework can separate the two steps of
1: Saying that an object has changed
2: Deciding what actions should occur when an object has changed
This is what ZPatterns does with DynPersist.so (for the setattr hook)
for 1, and Triggers/Agents/"WHEN OBJECT CHANGED" SkinScript for 2.
At the EuroZope conference, Mike P. said something about Jim Fulton
thinking about making Transaction pluggable in some form or other. I
need to ask Jim about this soon.
--
Steve Alexander
Software Engineer
Cat-Box limited