Re: [Zope] error with simple python script loop
now i shrink my test script to one line ;) ### for i in range(2): context.MailHost.send('bodytext', "rec@mail.com", "sender@mail.com", 'subj'+str(i)) ### The error occured with IE, with Firefox i cant replicate the error. Here is the output of the Z2.log when calling the script over URL directly. localhost- christian [24/Nov/2006:23:48:27 +0200] "GET /VirtualHostBase/https/dev.***.de:443/VirtualHostRoot/Christian/rangeEMAIL.p y HTTP/1.1" 204 210 "" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)" localhost- christian [24/Nov/2006:23:48:28 +0200] "GET /VirtualHostBase/https/dev.***.de:443/VirtualHostRoot/Christian/rangeEMAIL.p y HTTP/1.1" 204 210 "" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)" localhost- christian [24/Nov/2006:23:52:13 +0200] "GET /VirtualHostBase/https/dev.***.de:443/VirtualHostRoot/Christian/rangeEMAIL.p y HTTP/1.1" 204 210 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1) Gecko/20061010 Firefox/2.0" tomorrow i will check the zdb debugger with the script. thx for the hints to solve the problem.
----- Original Message ----- From: "Christian Steinhauer" <steinhauer@know-it.net> To: <zope@zope.org> Sent: Friday, November 24, 2006 6:08 PM Subject: Re: [Zope] error with simple python script loop
now i shrink my test script to one line ;)
### for i in range(2): context.MailHost.send('bodytext', "rec@mail.com", "sender@mail.com", 'subj'+str(i)) ###
The error occured with IE, with Firefox i cant replicate the error. Here is the output of the Z2.log when calling the script over URL directly.
localhost- christian [24/Nov/2006:23:48:27 +0200] "GET /VirtualHostBase/https/dev.***.de:443/VirtualHostRoot/Christian/rangeEMAIL.p y HTTP/1.1" 204 210 "" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"
localhost- christian [24/Nov/2006:23:48:28 +0200] "GET /VirtualHostBase/https/dev.***.de:443/VirtualHostRoot/Christian/rangeEMAIL.p y HTTP/1.1" 204 210 "" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"
localhost- christian [24/Nov/2006:23:52:13 +0200] "GET /VirtualHostBase/https/dev.***.de:443/VirtualHostRoot/Christian/rangeEMAIL.p y HTTP/1.1" 204 210 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1) Gecko/20061010 Firefox/2.0"
If you think it may be an IE browser problem, ieHTTPHeaders may be of some help: http://www.blunck.se/iehttpheaders/iehttpheaders.html Jonathan
What a nice tool. Now more debugging with some interesting results. ### for i in range(2): context.MailHost.send('bodytext', "rec@mail.com", "sender@mail.com", 'subj'+str(i)) ### This script produces: HTTP/1.1 204 No Content ### for i in range(25): subj = str(i+1) + ' range python' context.MailHost.send('Range Python', "rec@mail.com", "sender@mail.com", subj) ### This script produces: HTTP/1.1 204 No Content ### for i in range(2): context.MailHost.send('bodytext', "rec@mail.com", "sender@mail.com", 'subj'+str(i)) context.emailcounter.write(str(int(context.emailcounter())+1)) ### This script produces: HTTP/1.1 200 OK The third script has no output on the screen too but works fine and gives HTTP Code 200 back. Can you tell me why he do this?
The third script has no output on the screen too but works fine and gives HTTP Code 200 back. Can you tell me why he do this? This is because of call to ZPT in your third script. ZPT call sets RESPONSE HTTP headers with content/type='text/html'. Try this:
for i in range(2): context.MailHost.send('bodytext', "rec@mail.com", "sender@mail.com", 'subj'+str(i)) container.REQUEST.RESPONSE.setHeader('content-type', 'text/html') And you should get 200 OK status too. You may compare these results from IE with results from Firefox. There is LiveHttpHeaders plugin for FF that will show you similiar output as above (but in FF environment). In general seems that it is a IE bug. -- Maciej Wisniowski
Christian Steinhauer wrote:
What a nice tool. Now more debugging with some interesting results.
### for i in range(2): context.MailHost.send('bodytext', "rec@mail.com", "sender@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 ;-) cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris Withers wrote at 2006-11-27 16:16 +0000:
... Moral of the story: if you want sane things to happen, make sure your script returns a string output.
In fact, an empty string would result in the same behaviour. Thus, the moral should be: make your your script does not return a Python false value. As returning nothing, means returning "None" which is a Python false value, this implies, return something. -- Dieter
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 25 Nov 2006, at 00:08, Christian Steinhauer wrote:
localhost- christian [24/Nov/2006:23:48:27 +0200] "GET /VirtualHostBase/https/dev.***.de:443/VirtualHostRoot/Christian/ rangeEMAIL.p y HTTP/1.1" 204 210 "" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"
localhost- christian [24/Nov/2006:23:48:28 +0200] "GET /VirtualHostBase/https/dev.***.de:443/VirtualHostRoot/Christian/ rangeEMAIL.p y HTTP/1.1" 204 210 "" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"
This output *clearly* tells you that IE is requesting the resource twice in quick suggestion. This is not a Zope problem, it is an IE problem. jens -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFFZ5axRAx5nvEhZLIRAhxgAJ9PFhi/PPkwzKQamCELzE9feVYX3QCghqt0 qhS+g/jLJsRzjBH6M7np5VA= =QGVM -----END PGP SIGNATURE-----
participants (6)
-
Chris Withers -
Christian Steinhauer -
Dieter Maurer -
Jens Vagelpohl -
Jonathan -
Maciej Wisniowski