Log in |
Using cron with ZopeOne of the big difficulties people have with a "100% pure Zope" sollution is that Zope is, after all, user-driven. There is (apparently) no way of executing some task periodically, or in response to a mail message. Well, these premises are not actually true. Yes, things only happen in Zope when someone makes a request (via HTTP, FTP, the Monitor, or whatever else someone happens to add in the future). However, it isn't really difficult to fulfill this simple requirement. Let's assume you have a queue of comic strips; you want to allow the author to upload a new one anytime he wishes, but you want it to only go live by midnight (local time). In a static webserving world (and an Unix-like system, of course), you would store the queue somewhere, as physical files, and then use a cron job to move the oldest file in the queue to the static page everyday. Well, the good news is that you can do exactly that with Zope. Here are the steps you must follow:
With this command, if the method is successful, cron will consider everything OK; if the method fails, Zope will return an error page, which lynx will dump, which cron will consider an error and mail back to you! Security considerationsYou don't want to have your Manager password in /etc/crontab or somewhere as visible as that - not to mention that it will appear to anyone who happens to type "ps ax" on the machine while the job is running. So, create a "cron" user as high as you can in the Zope hierarchy, then don't grant it any useful powers, except running these methods. Other useful toolsThere are other things you can use instead of lynx; for example, with wget: "wget -O - --http-user=username --http-password=password http://somewhere.foo/path/to/script". In this case, it is possible to save the password in a config file, and then use the standard filesystem security to keep it safe; consult the wget documentation about how to do that. If you need anything more complex than running a simple script with no parameters, take a look at XML-RPC. |