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

horst wald horstwald_@hotmail.com
Tue, 02 Jul 2002 09:26:47 +0000


>alwyn@smart.com.ph writes:
>  > Is it then possible for example to have pieces of Python code start up 
>when
>  > zope start up that will be persistent and executing for as long as zope
>  > runs?

I found a rather dirty solution:

1. install a root-cronjob:

* * * * * python /pathtopieceofcode/pieceofcode.py

2. pieceofcode.py lokks like:

import os,string

while 1:
noofmyinstances=0
noofzopeinstances=0
for line in os.popen('ps -aux').readlines():
  if string.find(line, 'python /pathtopieceofcode/pieceofcode.py')>-1:
   noofmyinstances+=1
  if string.find(line, 'python /pathtozope/z2.py')>-1:
   noofzopeinstances+=1
if noofzopeinstances==0 or noofmyinstances>1:
  # the instance counts itself, too
  break

# here comes your piece of code

>Look at Zope's database adapters for an example on how to
>connect to external systems...

Dieter, that sounds interesting but such advice only helps you if you have 
already reached a rather high level of understanding. I'd like to know how 
to connect to external systems myself, I looked at ZMySQLDA and now I'm just 
as stupid as I was before. I see tons of code most of which is not important 
to my question and I can't find the relevant parts.

Horst

_________________________________________________________________
Werden Sie Mitglied bei MSN Hotmail, dem größten E-Mail-Service der Welt: 
http://www.hotmail.com/de