Re: Question about soup_form_request_new() functions




----- Original Message -----
> Hi,
> 
> I've been test driving libsoup from Python using PyGObject's
> introspection capabilities [1] and have stumbled across an oddity
> with the Soup.form_request_new() family of functions:
> 
> I've been trying to construct a SoupMessage instance of method=POST,
> where the application/x-www-form-urlencoded data should look like
> this: series=X&series=Y&series=Z (to simulate a user selecting
> multiple OPTION's from a SELECT and submitting the form).
> 
> Looking at the soup_form_request_new* family of functions, I've tried:
> 
> - form_request_new(): this function doesn't seem to be available [2]
> - form_request_new_from_datalist(): looking through the various .gir's
> there's no way I can see how to construct a GData that can be passed
> as a parameter to this function
> - form_request_new_from_hash(): Aha! We can pass a Python dict here.
> But then obviously a Python dict can't have multiple keys with the
> same value [3]. I suspect a GHashTable would behave in the same way.
> 
> So, any ideas on how I can construct a SoupMessage instance as
> described?
> 
> Thanks,
> Dieter
> 
> [1] Python 2.7.1, PyGObject 2.28.4, GObject Introspection 0.10.8
> and libsoup 2.34.2
> 
> [2] ~ $ python -c "import sys;from gi.repository import Soup;
> [sys.stdout.write('%s\n' % x) for x in dir(Soup)];" | grep form_
> form_decode
> form_decode_multipart
> form_encode_datalist
> form_encode_hash
> form_request_new_from_datalist
> form_request_new_from_hash
> form_request_new_from_multipart
> 
> [3] ~ $ python -c "print {'series': 'X', 'series': 'Y', 'series':
> 'Z'}"
> {'series': 'Z'}
> 

Yes, those are all pretty much unscriptable APIs except for the hash. You would need to request a new API from the libsoup devs.  I suggest one that takes a GSList of strings where the even entries and the 0 entry are names and the odd entries are values.

--
John (J5) Palmieri
Software Engineer
Red Hat, Inc.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]