[Grok-dev] Re: Using POST request

Martijn Faassen faassen at startifact.com
Fri Mar 21 14:06:27 EDT 2008


Uli Fouquet wrote:
> Hi there,
> 
> Martijn Faassen wrote:
> 
>> Note that the alternative pattern would be to use an Index view:
>> 
>> class Index(grok.View): grok.context(eggserver) def render(self): 
>> if self.request.method == 'POST': ....
>> 
>> It's weird though that the REST story doesn't seem to be working; I
>>  suspect we're missing something simple, but what?
> 
> Worse: also the view seems not to work with setup.py requests (Grok 
> 0.11.1):

[snip]

> This should at least return _something_ in case of POST requests, 
> shouldn't it? For simple, malformed POST requests, this is the case::
> 
[snip]

> Connection closed by foreign host.
> 
> It also works for GET and for browser generated POST requests of any 
> kind (url-encoded and multipart/form-data). But not for setup.py POST
>  requests.

Thanks Uli for examining the request here; I hadn't considered that the 
contents of the POST request is affecting the behavior here!

Strange! With 0.11 (I haven't tried 0.11.1 yet), I have this working
with POST requests that contain XML data and even raw file data, nothing 
like a multipart/form request. I can't think of anything in 0.11.1 that 
would break this..

> The view object is even not created upon request, although setup.py 
> sends a complex but (at first glance) regular POST request. The same
> is true for Andreas' ``MyREST2`` class. It is even not asked for
> generating content (for GET requests it works, also for browser
> generated multipart/form POST requests). What's wrong here? Maybe
> something strange in the setup.py request? Anyway, the problem does
> not seem to be REST specific.

Well, Grok's REST code is making use of the normal Zope publisher 
handlers for GET and POST, so possibly something in there is going on 
that breaks things. I do recall that the zope publisher wants to process 
the POST body as form data even if the headers claim it contains no such 
thing, and thus you get a pretty weird request.form when doing REST. It 
wouldn't error out though. Not pretty, and I'd prefer if it could skip 
this step, but you'd not look at this anyway.

Does setup.py do a multipart/form style POST request, or does it send 
something different altogether?

Regards,

Martijn



More information about the Grok-dev mailing list