[Setup] Re: Content expiration workflow

Stephen Kenworthy steveyken at gmail.com
Wed Feb 8 02:28:11 UTC 2006

We currently do something similar (time-based workflow transition)

Our setup is:
   * python script that searches for all content in particular workflow 
state and performs the correct transition
   * cron job to automatically call the script at particular intervals

In your case you could search for all content that is 'expired' and 
perform that workflow transition 'submit'.

Here's a partial example of code that we use:

# Apply a workflow transition after a period of time

from DateTime import DateTime
import time

def applyTransition(self, transition, time_offset):
     pc = self.portal_catalog
     pw = self.portal_workflow

     t0 = DateTime(time.time() - time_offset * 3600)

     pending = 0
     promoted = 0

     # Grab all of the offers that are only visible to premium members

     for obrain in pc.queryCatalog({'portal_type':"OfferFolder", 
         o = obrain.getObject()
         last_transition = o.workflow_history['offer_folder_workflow'][-1]
         t1 = last_transition.get('time')

         pending += 1
         # Check to see if this offer has passed the blackout period
         pending_objs = {}
         if t1 < t0:
             promoted += 1
             # TODO: currently it silently ignores objects who's 
transition does not exist
             for t in pw.getTransitionsFor(o):
                 if t['id'] == transition:
                    pw.doActionFor(o, transition)

         pending_objs[pending] = o.absolute_url()

Sean Dodsworth wrote:
> Hi all,
> I want to set up a workflow that automatically submits content for 
> review (by changing its state) when it reaches its expiration date.
> I'm using Plone 2.1.1
> Any ideas?
> -Sean

More information about the Setup mailing list