[Zope] Using zope as something more than just dynamic webpages

Toby Dickenson tdickenson@geminidataloggers.com
Tue, 2 Jul 2002 11:24:14 +0100


On Tuesday 02 Jul 2002 11:03 am, Paul Winkler wrote:

> If by "executing" you mean "running a loop indefinitely",
> maybe you could do something like (untested)
>
> - make a Product by copying the "Boring" product
>
> - in Boring.py (or whatever you call it),
>    add this to the end of __init__():
>
>     import time
>     delay_seconds =3D 1
>     while 1:
>         # your code goes here
> =09time.sleep(delay_seconds)
>
> - Add an instance of this product somewhere in your zope tree.
>
> Your code should then start running sometime before Zope
> finishes starting up, and will run as long as Zope is up.


With that code, Zope will never finish starting up :-)

You need to run that code in its own thread, with the appropriate magic t=
o use=20
yor own ZODB transaction. Take a look at the Xron product, which does exa=
ctly=20
this.