[Zope] Importable Xron

Loren Stafford lstaffor@dynalogic.com
Wed, 9 Aug 2000 14:45:58 -0700


Xron is alpha-level software, which means (among other things) that it is
new, hasn't received a lot of use, doesn't have a lot ready examples, may be
lacking documentation quantity or quality. If you want to use Xron in its
current alpha state you must be willing to invest a little effort in
learning to use the product. For my part, as developer of the product, I am
willing to guide you through the process on mailto:zope@zope.org and thereby
create a documentation trail here on the mailing list that others can use
and that can be distilled into more documentation and examples.

So if you are ready, so am I. But, for me to guide you, I will need to ask
you to be more specific about your experience level, what relevant documents
you have read, what specifically in the document you didn't understand, what
tutorials you have followed, what attempts you have made to use the product,
what errors resulted, etc.

First, to make repetitive events, you must create a ZClass. Have you read
the ZClass documentation and How-To's? Have you created a ZClass before? If
not, I recommend that you do so before we continue.

From: "Peter Bengtsson" <peter@grenna.net>


> I want to use the Xron product but I don't understand how to use it.
> (http://www.zope.org/Members/lstaffor/Xron/)
>
> All this Zope Zen jargon makes me dissy. What I don't understand is where
> and why to put reschedules at certain places.

You have to create a ZClass that is just like Xron DTML Method class, except
that it calculates the time that the event will next occur based upon the
needs of your application. You create your ZClass in Control Panel /
Products. When you create your ZClass, you will be asked what classes to
base it on (subclass from); you must select Xron DTML Method.

If you do nothing else, your ZClass will behave exactly like Xron DTML
Method class. But you want it to do something different. You what it to
calculate the next time for the event. Xron DTML Method makes its default
calculation in the method 'reschedule'. You want to replace 'reschedule'
with your own calculation. You do that by adding a DTML method, named
'reschedule' to you new ZClass. There's a simple example in the README.txt
for Xron.

> Subclasses and DTML
> Methods...etc.
>
> Can you please include a importable zexp on the download page of Xron.
>
> I want to do one single simple thing for now.
> Send the <dtml-var webmaster> constant information about various site
stats.

Do you already have methods that gather the site stats?

> These should be sent weekly or hourly or monthly.

You could make a separate ZClass subclass of Xron DTML Method for  weekly
events, another for hourly events, and another for monthly events. Or you
could create a single subclass that determines whether to reschedule for
next hour, next week, or next month. It's your design decision. I'd
recommend starting with just "next hour", as a learning exercize. That way
it won't take more than an hour find out whether your application works.

> I also want to have more than one instance of Xron.

You probably don't want more than one instance of Xron. Xron contains three
major parts: the Schedule, the Dispatcher thread, the Xron DTML Method
class. Any single system needs only one Schedule and one Dispatcher thread.
What  you probably need are multiple instances of the Xron DTML Method class
or of the subclass you create. Each one of these instances would be a
procedure that you want to execute at specific times. Suppose, for example,
your subclass of Xron DTML Method is called "Weekly Event" and its
reschedule method calculates the next event time thus:

    <dtml-call "REQUEST.set('XronEventTime', REQUEST.XronEventOldTime +
7.0)">

Then, you would create Weekly Event objects (also called "instances") for
each action that you want to execute weekly. Each Weekly Event instance will
be executed by the Dispatcher once a week. What a Weekly Event object
actually does when executed is determined by the DTML content of that
instance. You could have one Weekly Event that gathers, site statistics. You
could have another Weekly Event that sends you an email reminding you to
take out the garbage.

>
> Can somebody give me examples. Especially how you set the date and time.
> (I have no experience of cron and I live in GMT+0)

Experience with cron will not help you with Xron -- they are only similar in
general purpose, not in details of implementation nor interface.

You (because you are in GMT+0) can enter dates like this

    August 9, 2000 14:27:00 GMT

Most common unambiguous date formats are accepted; for example

    Aug 9, 2000 14:27:00 GMT
    2000/08/09 14:27:00 GMT
    9 Aug 2000 14:27:00 GMT

Detailed documentation is in ../lib/python/DateTime/DateTime.py

>
> Grateful, Peter
> Peter Bengtsson - OD Consultancy
>

Glad to help.

-- Loren