[Zope-CMF] DCWorkflow: detecting changes to object
Tres Seaver
tseaver@zope.com
21 Jun 2003 10:30:12 -0400
On Sat, 2003-06-21 at 03:27, Paul Winkler wrote:
> I've been tasked with creating a workflow that sends an email
> notification anytime an object is created or changed by ftp
> or webdav upload. This workflow is not used for anything other
> than triggering these emails.
>
> I've handled creation successfully, by creating two states
> ("new" and "notification sent"), and an automatic transition
> from the former to the latter. The transition ("notify")
> has as its guard expression "python:1", and after the state
> change it calls a script that sends email. "new" is set as
> the initial state.
>
> That works just fine. But it seems that re-upload of an existing
> object counts as modification, not delete & create. So
> in this case, the email is not sent - and we need it to be sent.
>
> I think what I need is a guard expression that says something like
> "Trigger this transition if the object's modification time is
> less than the last time I triggered this transition for this object."
> But I can't figure out how to do that. Any suggestions?
1) Use a WorkflowMethod wrapper for PUT:
from Products.CMFCore.WorkflowCore import WorkflowMethod
...
def PUT( self, REQUEST, RESPONSE ):
....
PUT = WorkflowMethod( PUT )
Then, add a "modify" transition to your workflow, which both
starts and ends in the 'notification sent' state.
2) Use the catalog as an event channel: register a custom index whose
only job is to leverage the calls to 'indexObject' to send your
e-mail.
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com