Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52563 > unrolled thread

question about posting data using MultipartPostHandler

Started bycerr <ron.eggler@gmail.com>
First post2013-08-15 11:12 -0700
Last post2013-08-16 01:45 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  question about posting data using MultipartPostHandler cerr <ron.eggler@gmail.com> - 2013-08-15 11:12 -0700
    Re: question about posting data using MultipartPostHandler Chris Angelico <rosuav@gmail.com> - 2013-08-16 01:45 +0100

#52563 — question about posting data using MultipartPostHandler

Fromcerr <ron.eggler@gmail.com>
Date2013-08-15 11:12 -0700
Subjectquestion about posting data using MultipartPostHandler
Message-ID<3c256548-5fed-446a-8683-b66abc0e301f@googlegroups.com>
Hi,

I want to use http post to upload data to a webserver but I want to pass multiple arguments within the post i.e.
I know that you can load one item (data)in there like this:
			data = {"data":open(filename,"rb")}
			response = opener.open(url, data, timeout=TIMEOUT)
but now I want multiple so I tried this:
        multipart = ({"data":data}, {"fname":fname}, {"f":f})
        response = opener.open(url, multipart, timeout=TIMEOUT)

but I get an error saying "'tuple' object has no attribute 'items'"... how do I do this correctly?

Thank you!
Ron

[toc] | [next] | [standalone]


#52571

FromChris Angelico <rosuav@gmail.com>
Date2013-08-16 01:45 +0100
Message-ID<mailman.611.1376613911.1251.python-list@python.org>
In reply to#52563
On Thu, Aug 15, 2013 at 7:12 PM, cerr <ron.eggler@gmail.com> wrote:
>         multipart = ({"data":data}, {"fname":fname}, {"f":f})
>
> but I get an error saying "'tuple' object has no attribute 'items'"... how do I do this correctly?

You're no longer providing a dictionary, but a tuple of dictionaries.
What you want to do is use a single dictionary:

multipart = {"data":data, "fname":fname, "f":f}

That should achieve what you want.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web