From: Mitchell L Model on 3 Mar 2010 14:54 On Mar 2, 2010, at 4:48 PM, I wrote: > Can someone tell me how to upload the contents of a (relatively > small) file using an HTML form and CGI in Python 3.1? As far as I > can tell from a half-day of experimenting, browsing, and searching > the Python issue tracker, this is broken. followed by a detailed example demonstrating the problem. Having hear no response, let me clarify that this request was preliminary to filing a bug report -- I wanted to make sure I wasn't missing something here. If nothing else, this failure should be documented rather than the 3.1 library documentation continuing to describe how to upload file contents with POST. If someone thinks there is a way to make this work in 3.1, or that it isn't a bug because CGI is hopeless (i.e., non-WSGI-compliant), or that the documentation shouldn't be changed, please respond. I'd rather have this particular discussion here than in the bug tracking system. Meanwhile, let me heartily recommend the Bottle Web Framework (http://bottle.paws.de ) for its simplicity, flexibility, and power. Very cool stuff. To make it work in Python3.1, do the following: 1. run 2to3 on bottle.py (the only file there is to download) 2. copy or move the resulting bottle.py to the site-libs directory in your Python installation's library directory 3. don't use request.GET.getone or request.POST.getone -- instead of getone, use get (the protocol changed to that of the Mapping ABC from the collections module) 4. the contents of a file will be returned inside a cgi.FieldStorage object, so you need to add '.value' after the call to get in that case
|
Pages: 1 Prev: GZRBOT 0.2 BETA1 released Next: Old farts playing with their toys (was: Docstrings...) |