Questions tagged [webob]

Any questions regarding WebOb and its usage in Python WSGI applications.

WebOb is a Python library that provides wrappers around the WSGI request environment, and an object to help create WSGI responses. The objects map much of the specified behavior of HTTP, including header parsing, content negotiation and correct handling of conditional and range requests.

This helps you create rich applications and valid middleware without knowing all the complexities of WSGI and HTTP.

Documentation: WebOb Read the Docs
Source Code: WebOb on Github
Issue Tracker: Github Issues

38 questions
11
votes
3 answers

How to convert a MultiDict to nested dictionary

I would like to convert a POST from Webob MultiDict to nested dictionary. E.g. So from a POST of: 'name=Kyle&phone.number=1234&phone.type=home&phone.number=5678&phone.type=work' to a multidict; [('name', 'Kyle'), ('phone.number', '1234'),…
Kyle Finley
  • 11,842
  • 6
  • 43
  • 64
8
votes
3 answers

WMS/WFS server: am I crazy to write my own?

I'm a "do it yourself" kind of guy, but I want to make sure I'm not going to do myself in by trying to bite off more than I can chew. I am writing a browser-based mapping application that needs to have the option to run standalone (no internet…
M Katz
  • 5,098
  • 3
  • 44
  • 66
7
votes
2 answers

Webapp2 Python set_cookie does not support samesite cookie?

In webapp2 documentation there is no mention of setting the SameSite attribute for a cookie, it seems to be built on the response handler from WebOB, I checked webOB doc page it clearly shows the 'SameSite' flag as an accepted cookie parameter I…
Khaled
  • 907
  • 1
  • 8
  • 18
6
votes
3 answers

How to create cgi.FieldStorage for testing purposes?

I am creating a utility to handle file uploads in webob-based applications. I want to write some unit tests for it. My question is - as webob uses cgi.FieldStorage for uploaded files I would like to create a FieldStorage instance in a simple way…
zefciu
  • 1,967
  • 2
  • 17
  • 39
5
votes
2 answers

How do you restrict large file uploads in wsgi?

I'm trying to get an understanding of the best way of handling file uploads safely in a wsgi app. It seems a lot of solutions involve using FieldStorage from the cgi module to parse form data. From what I understand about FieldStorage it performs a…
Will
  • 1,149
  • 12
  • 25
5
votes
1 answer

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

Suppose I have a form like this:
Favorite colors? Green Blue Red …
GDorn
  • 8,511
  • 6
  • 38
  • 37
5
votes
1 answer

What could cause a Block stack underflow in python?

The Application Context We are developing an experimental web Framework using "solely" WebOb. We are handling concurrent requests and it's basically a quite simple integration of WebOb. We are hosting our application on webfaction.com The thing is…
David Dugué
  • 155
  • 2
  • 9
3
votes
2 answers

How can I build a file-upload POST HTTP request with WebOb?

I am using Ian Bicking's WebOb to very great effect in writing Python web application tests. I call webob.Request.blank('/path...'), and then use the resulting request object's get_response(app) method to invoke my web application. The response…
Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147
3
votes
1 answer

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. …
Derek Dahmer
  • 14,865
  • 6
  • 36
  • 33
3
votes
1 answer

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…
Pavel Repin
  • 30,663
  • 1
  • 34
  • 41
2
votes
0 answers

sending chunks of data using webob

I tried to write a simple server-client program using webob. 1. The client send data using 'Transfer-Encoding', 'chunked' 2. the received data is then print in the server side. The Server.py received the data correctly. However, I got error a bunch…
prgbenz
  • 1,129
  • 4
  • 13
  • 27
2
votes
1 answer

I'm using Pylons and having issues with response.set_cookie

I am thinking one of the versions of Pylons is different but I could not find an easy way to tell what versions I was running. In the first example I am fairly certain it is 0.9.7 and up using webob to set the cookie. This environment is setting the…
Skylude
  • 494
  • 4
  • 8
  • 18
2
votes
3 answers

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…
Freewind
  • 193,756
  • 157
  • 432
  • 708
2
votes
1 answer

how to attach a BytesIO object to a Webob.Response Object

I'm returning a Webob.Response object from my server to http request. The server puts together a BytesIO object. How can I correctly attach the BytesIO object to the Webob.Response object? I tried: app_iter = FileIter(BytesIO_Object) return…
Abdul Ahmad
  • 9,673
  • 16
  • 64
  • 127
2
votes
1 answer

How to patch instances in __init__ method of a class?

I am writing a unittest. How can I patch self.conf in the init method in class MyValidator? In my unittest, I want to create a fake self.conf and get the response to make assertion of each element in self.conf. class MyValidator(wsgi.Middleware): …
James C.
  • 501
  • 2
  • 7
  • 16
1
2 3