[Zope] error with simple python script loop

Christian Steinhauer steinhauer at know-it.net
Mon Nov 27 13:17:37 EST 2006


 
>>>   context.MailHost.send('bodytext', "rec at mail.com",
>>"sender at mail.com",
>>> 'subj'+str(i))
>>> ###
>>> This script produces: HTTP/1.1 204 No Content
>>
>>Moral of the story: if you want sane things to happen, make sure your 
>>script returns a string output.
>>
>>Otherwise you risk tickling some of the more arcane "features" of Zope 
>>2's publisher. They include "no content"
>>responses if you return None and even weirder things if you return a 
>>two-element tuple.
>>
>>This isn't a bug, you're doing something silly, stop doing it ;-)

Here i must add that it is an test script for the list only, the real script
which has produce the error is bigger and it has an output of string. But
the part which is sending the mail has produce the double emails, so i debug
this part. 

Here is a bit of the original script, so tell me again why i get the error,
because it has an string output. 

###
recp_list = []
request.set('Query','SQL SELECT')

for i in context.sql_query():
  mMsg = 'test'
  mTo = str(i["m_to"])
  mFrom = str(i["m_from"])
  mSubj = str(i["l_subject"])
  context.MailHost.send(mMsg, mTo, mFrom, mSubj)
  recp_list.append(i["u_email"])

recp_output = str(recp_list)
mRet = 'E-Mails send to:<br>' + recp_output + '<br><br>'
return mRet
###

This script is the part of the devil ;) It has produce the double emails, i
have cut some lines codes to get it faster to understand. 

- cs



More information about the Zope mailing list