You are here: Home Plone products Plone Maintenance

Plone Maintenance (1.4.2)

1
by Ihor Berehulyak last modified 2009-01-08
0.0
0.0
0.0
0.0
Released on 2007-08-29 by Ingeniweb for Plone 2.1, Plone 2.5 under GPL - GNU General Public License available for All platforms.
Software development stage: stable
Run cheduled scripts for routine work in a Plone site, like packing the ZODB.
PloneMaintenance consists of a portal_maintenance tool that allows you to define maintenance tasks and scripts to run according to a schedule assigned to the tasks.

No task is going to be run unless it is scheduled to. The schedule information is stored in the task, and even if PloneMaintenance is called many times in a row, it will always look up the schedule information, check when was the last time the task was run, calculate the next time the task is scheduled to run, and depending on this, PloneMaintenance will decide whether it runs the script associated to the task or not.

PloneMaintenance depends on an external tool to wake it up and make it execute the scheduled tasks. Without an external tool, PloneMaintenance will just sit and wait, doing nothing. You can go to the portal_maintenance tool and manually run the maintenance tasks, but most of the time, you want an external tool doing the job automatically.

You can choose one of the Schedulers which are available for Zope, or call PloneMaintenance from a cron job.

Zope 2.6: * http://www.zope.org/Members/lstaffor/Xron

Zope 2.7: * http://dev.legco.biz/products/ZopeScheduler * http://dev.legco.biz/products/timerservice

How PloneMaintenance works

When the PloneMaintenance tool is called, it locks itself using the _v_running variable. The next time a schedule is started, this lock will prevent the execution of the Tasks so that tasks that take a long time to execute are protected.

When a Task is created, an initial execution time is stored, although this does not mean we start the Task right away.

The PloneMaintenance tool executes one Task after the other, always storing the execution date. At the end, the lock is removed.

PloneMaintenance computes the next execution time given the current date and compares it to the next execution date, given the last execution date. If the two calculated dates are the same, it does nothing, otherwise it runs the task.

Tasks are added to the portal_maintenance tool. They have a "script_name" property that names the script which they execute, and they have a "last_execution_date", which stores the last time the task was executed.

Scripts are also added to the portal_maintenance tool. They can be normal Python Scripts.

Here is an example of a Maintenance Script for a Plone site:

# Script for packing the ZODB:
# (Already integrated into PloneMaintenance)

dbs=context.Control_Panel.Database
if 'main' in dbs.getDatabaseNames():
try:
dbs['main'].manage_pack(days=0)
except:
pass
Document Actions
Powered by Plone