OK, it's been a while, but WebOb trunk now has a two-fold fix for this. First, your POST won't be reparsed when you have middleware that accesses POST and then an app that also accesses POST. Next, file upload POST bodies are also generated properly.
As a side effect req.GET and req.POST are now usefully writable; changes are reflected in QUERY_STRING and wsgi.input respectively. The one detail left now is to make these attributes settable. On Fri, May 15, 2009 at 2:57 PM, John Smallberries<[email protected]> wrote: > > I've inserted a simple middleware class into my wsgi stack and > suddenly the POST dictionary is empty when handling a file upload form > submission. > > class MyMiddleware(object): > def __init__ > (self,app,config=None,environ_key='my.stuff',**kwargs): > self.app = app > > def __call__(self, environ, start_response): > req = Request(environ) > log().info("handling request %s" % req) > log().info("request.POST= %s" % req.POST) > resp = req.get_response(self.app) > return resp(environ, start_response) > > I've appended the log output when a file upload post goes by, showing > the request headers and body. Why's the POST dict not being populated > with the upload and case_number variables? The self.app/controller > throws a KeyError during get_response(). This controller works fine > when the middleware is not there. > > Logfile output from the above: > > 2009-05-15 12:45:31 INFO handling request POST /testform > Accept: text/xml,application/xml,application/xhtml+xml,text/ > html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 > Accept-Encoding: gzip, deflate > Accept-Language: en-us > Cache-Control: max-age=0 > Connection: keep-alive > Content-Length: -1 > Content-Type: multipart/form-data; boundary=---- > WebKitFormBoundaryGA7kzcYGAhBstwLx > Host: localhost:5000 > Referer: http://localhost:5000/ > User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) > AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1 > > upload=FieldStorage%28%27sysdump%27%2C+%27Case_45815_sysdump-Woking- > Bisley-20080702-163019.tgz%27%29&case_number= > > 2009-05-15 12:45:31 INFO request.POST= MultiDict([]) > > > > > > -- Ian Bicking | http://blog.ianbicking.org | http://topplabs.org/civichacker --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
