[Zope] Real time triggers in Zope

Paul Everitt paul@zope.com
Sat, 22 Sep 2001 17:17:44 -0400


Brendon Grunewald wrote:

> Hi Zopistas
> 
> I'm trying to create a notification / trigger function in Zope. Since there
> are typically a couple of ways to implement things in Zope, I'd like to hear
> some suggestions on how to accomplish the following:
> 
> 1. Trigger an article to become displayed at or after a certain date and
> time. Like preloaded press releases that are then "released" for view at the
> given date. Or pages that are announced, or product details that are
> launched etc.


We at ZC have been fielding a number of RFPs for content management 
recently.  This is a common pattern.

Chris gave the right answers in his note, so I'll just parrot what he 
said. :^)  The CMF simulates this kind "release" by simply not allowing 
the item to be viewable until the effective date.  It doesn't, though, 
really change the state of the item when it becomes effective.

Note that what's really wanted here is a workflow event that somehow 
gets triggered based on clock ticks.  You find all the content that 
matches the criteria and move the content to the next state.

For now, the simplest thing to do is write a cron job that tickles a 
Python script every minute.  The Python script then does a catalog 
request to find everything that has an effective date past "now" that 
hasn't been published, and changes the content to published.  This 
presumes that all of your content is catalog-aware.  If not, you have 
one heck of a find sweep ahead of you.

Obviously, make sure that your Python script is pretty resilient with 
exception handlers.  Also, make sure your cron job is pretty smart about 
detecting that the Python script didn't run to completion, and thus 
emails you something from stderr.

Alternatively, try Xron as Chris suggested.  It seems to be pretty old, 
so it might not work for recent releases of Zope.  But Xron is the right 
kind of approach.

Boy, I sure would like to see something like this become part of CMF or 
Zope in the future!


--Paul