Titus Brown wrote: > On Sun, Dec 02, 2007 at 04:03:46PM -0800, iain duncan wrote: > -> Hey guys, wondering if I can do an arbitrary post from twill using all > -> the handy shortcuts if the form I want to pretend to be does *not* > -> exist. > -> > -> Ie, from a python method I want to post a set of key/vals to an > -> arbitrary url, but use twill commands. I didn't see this in the > -> examples. > -> > -> Thanks! > -> Iain > > hi Iain, > > I don't know exactly how to do this with twill (or, more importantly, > with mechanize -- getting twill to do it would be easy, given mechanize > functionality). It shouldn't be too hard, however. > > Note that this is of great value for testing AJAX code, too.
In case you aren't sure about what it looks like, a POST form is just a submission with a url-encode body (assuming you aren't doing file uploads, which are harder). In urllib/urllib2, if you do a POST you give the body as an argument, with urllib.urlencode(form_values) as the body. form_values can be a dict, or better a list of (key, value) tuples. -- Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org _______________________________________________ twill mailing list [email protected] http://lists.idyll.org/listinfo/twill
