----- Original Message -----
From: "Christian Steinhauer" <[EMAIL PROTECTED]>
To: <zope@zope.org>
Sent: Friday, November 24, 2006 7:12 AM
Subject: [Zope] error with simple python script loop
I have an problem with this little script. The script is in the zope
file structure and it is an -Script (Python)-
The script should send 2 emails over the mailhost, but it sends 4
emails. I have test this with maildrophost product too, same problem. I
have test it on Zope 2.10.0 and Zope 2.64. The problem is the same -
everytime.
This script produce the error:
#### start ####
for i in range(2):
subj = str(i) + ' range python'
context.MailHost.send('range test with python', "[EMAIL PROTECTED]",
"[EMAIL PROTECTED]", subj)
#### end ####
This script produce no error:
#### start ####
for i in range(2):
subj = str(i) + ' range python'
context.MailHost.send('range test with python', "[EMAIL PROTECTED]",
"[EMAIL PROTECTED]", subj)
return 'eof'
#### end ####
So if i make a return (not in the loop) the script works fine.
Can anybody tell me why? It feels like that there are any spaces in the
script and zope/python did not work correctly when there is no other
procedure after the for loop. I dont understand why he calls the loop
two times and produce 4 emails. There is no transactional error in the
error_log.
I just cut and pasted your code into a python script on my Zope installation
(2.9.2) and it worked as expected (ie. 2 emails sent). So something is
pooched in your installation.
A quick way to check to see if your script is looping more than you expect
is to do something like:
loopCheck = []
for i in range(2):
subj = str(i) + ' range python'
context.MailHost.send('range test with python', "[EMAIL PROTECTED]",
"[EMAIL PROTECTED]", subj)
loopCheck.append(subj)
return loopCheck
If you are getting only 2 iterations of the loop (as it should be), then
something is wrong with your MailHost (if this is the case try deleting it
and re-adding it). Another test: place a local copy of MailHost in the same
folder as your script and see what happens.
hth
Jonathan
_______________________________________________
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )