[Zope3-Users] getting post data in a Zope 3 view

2008-08-19 Thread Chris Withers
Hi All,

I have a view:

from zope.publisher.browser import BrowserView

class Receiver(BrowserView):

 def __call__(self):
 print self.request.bodyStream.read()
 return 'done'

...which I'm trying to test with the following script:

import socket
socket.setdefaulttimeout(5)
from httplib import HTTPConnection
c = HTTPConnection('localhost:8080')
c.request('POST','/@@wasp','foo',{'Content-type':'text/plain',
   'Content-length':3})
print c.getresponse().read()

...but the processing seems to hang in bodyStream.read() until the 
socket times out on the client side (ie: I get a timeout exception)
at which point the read() returns and shows what I'd expect.

What am I doing wrong?

cheers,

Chris


-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] getting post data in a Zope 3 view [moreinfo: paster]

2008-08-19 Thread Chris Withers
Chris Withers wrote:
 ...but the processing seems to hang in bodyStream.read() until the 
 socket times out on the client side (ie: I get a timeout exception)
 at which point the read() returns and shows what I'd expect.
 
 What am I doing wrong?

I should note that I'm using paster serve here, so I wonder if that 
has any bearing?

cheers,

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] getting post data in a Zope 3 view - paste.httpserver is the problem

2008-08-19 Thread Chris Withers
Chris Withers wrote:
 I should note that I'm using paster serve here, so I wonder if that 
 has any bearing?

Well no, but the fact that my deploy.ini contained the following:

[app:main]
use = egg:HelloWorld

[server:main]
use = egg:Paste#http
host = 127.0.0.1
port = 8080

..was the problem. Look's like Paste's httpserver doesn't handle this 
kind of post properly.

Changing the deploy.ini to the following solved the problem:

[app:main]
use = egg:HelloWorld

[server:main]
use = egg:zope.server#main
host = 127.0.0.1
port = 8080

cheers,

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] getting post data in a Zope 3 view [moreinfo: paster]

2008-08-19 Thread Chris Withers
Alek Kowalczyk wrote:
 I would suggest checking if the Content-Length value has been properly set.

Yep, httplib.HTTPConnection does this for you. I even checked that it 
works ;-)

cheers,

Chris

-- 
Simplistix - Content Management, Zope  Python Consulting
- http://www.simplistix.co.uk
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users