[Zope] cron job in zope

Harry Wilkinson harryw@nipltd.com
Wed, 30 Jan 2002 10:57:44 +0000


You can hook into Zope with Python, since it's just a big Python app.  It
might be best to write a shell script to set up the necessary environment
variables (eg ZOPE_HOME and PYTHONPATH) so that you can get Zope to
import/run properly, then call a Python script from the shell script.

Something like this maybe:

-----------------------

#! /bin/sh

if [ "$ZOPE_HOME" == "" ] ; then
    export ZOPE_HOME=/usr/local/zope/a_zope_base
fi
if [ "$INSTANCE_HOME" == "" ] ; then
    export INSTANCE_HOME=~/zope/a_zope_instance
fi

export PYTHONPATH=$ZOPE_HOME/lib/python
python $INSTANCE_HOME/Products/yourproduct/yourcronscript.py

--------------------------

As far as hooking into Zope goes, it should be the same (or similar) as it
is for unit testing.  Import Zope, instantiate a Zope app with Zope.app(),
and from there you can access Zope objects just like you would in a
product.

If you want to make requests to certain objects, you can do so with
Testing.makerequest.

Hope that's some help.


HarryW

On Wednesday 30 January 2002 9:06 am, Michel Vayssade wrote:
> Hi,
>
> is there a standard hook, to say to the zope server
> "execute the method Myproduct.mymethod" each day/hour/min ...
> (like a unix cron)
>
> (okay, I could use "brute force" sending an http://...request
>  directly from a cron shell script with telnet host 8080 ...)
>
> thanks,
> Michel