webob

How to construct a webob.Request or a WSGI 'environ' dict from raw HTTP request byte stream?

Suppose I have a byte stream with the following in it: POST /mum/ble?q=huh Content-Length: 18 Content-Type: application/json; charset="utf-8" Host: localhost:80 ["do", "re", "mi"] Is there a way to produce an WSGI-style 'environ' dict from it? Hopefully, I've overlooked an easy answer, and it is as easy to achieve as the opposite o...

Opening POSTed file with PIL Image

Using WSGI, webob and PIL, I'm trying to use Image.open() on a file directly from the request. However, Image.open() always throws the exception "cannot identify image file". The image is the only field, no other POST or GET variables are used. The file is coming from a standard HTML upload form with enctype="multipart/form-data". im...

Pylons: response renaming? Is there a better way?

Hi, I've got a Pylons controller with an action called serialize returning content_type=text/csv. I'd like the response of the action to be named based on the input patameter, i.e. for the following route, produced csv file should be named {id}.csv : /app/PROD/serialize => PROD.csv (so a user can open the file in Excel with a proper nam...

How do I use pylons (paste) webtest with multiple checkboxes with the same name?

Suppose I have a form like this: <form id='myform'> Favorite colors? <input type='checkbox' name='color' value='Green'>Green <input type='checkbox' name='color' value='Blue'>Blue <input type='checkbox' name='color' value='Red'>Red <input type='submit' value='Submit'> </form> How do I use webtest's form library to t...

Google App Engine Python WebApp framework supported self.error() codes.

Hi! I know we can return errors to requests by calling self.error(http_error_code_here). However, there are some error codes that don't seem to be supported. "Unsupported error code" comes out when I use error code 510. I used http://en.wikipedia.org/wiki/List_of_HTTP_status_codes as a reference for the error codes I am using. What ht...

How to redirect to a url with non-English characters?

I'm using pylons, and some of my urls contains non-English characters, such as: http://localhost:5000/article/111/文章标题 At most cases, it won't be a problem, but in my login module, after a user has logging out, I try to get the referer from the request.headers, and redirect to that url. if user_logout: referer = request.headers.g...

Fresh solr instance for every hudson test build

I'm building a test suite for a python site, powered by hudson. Currently, the workflow for a test run looks like: Pull down the latest version from the repository. Create a new mysql db and import schema file and some fixture data. Run tests, largely powered by webtest, which means not needing to run a web server. Delete mysql db. ...