Wyatt Baldwin wrote:
> On May 18, 4:57 pm, John Smallberries <[email protected]>
> wrote:
>> On May 18, 2:36 pm, Wyatt Baldwin <[email protected]> wrote:
>>
>>> Yes. I was just curious why you were doing that, because accessing
>>> request.POST directly would avoid this problem.
>> Do I have access to a pre-made request object at this point in the
>> stack? It's available once I'm down in a controller method, but
>> earlier than that using what you get by importing request from pylons
>> throws "exceptions.TypeError: No object (name: request) has been
>> registered for this thread". The handful of WebOb examples I've seen
>> all begin by wrapping environ in a Request.
> 
> Hm.. I guess that would depend on where your middleware is in the
> stack. It would have to be above PylonsApp. I'm not sure that's
> desirable though. Seems like there should be some straightforward way
> of accessing POST args in middleware.

Hi,

I'm running into a similar problem in Pylons 0.9.6. I have a simple middleware 
which copies the environ, wraps it in a paste WSGIRequest, checks the request 
for a parameter and then passes the environ to the inner app. When I do this, 
the inner app finds request.params to be an empty MultiDict. If I remove the 
middleware, request.params is populated fine.

Here's the relevant snippet:
def __call__(self, environ, start_response):
     req = WSGIRequest(environ.copy())
     if req.method in [ "PUT", "POST" ]:
         params = req.POST
     else:
         params = req.GET

     minimode = params.get('minimode')
     if not minimode:
         return self.app(environ, start_response)
     else:
         return self.mini(self.app(environ, start_response))


How do I access the POST body in my middleware without corrupting the data for 
further apps?

TIA,
   - kochhar

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to