The Artima Developer Community
Sponsored Link

Python Buzz Forum
WSGIRemote now HTTPEncode

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
WSGIRemote now HTTPEncode Posted: Mar 11, 2007 7:09 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: WSGIRemote now HTTPEncode
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

I renamed WSGIRemote to be HTTPEncode. The relation to WSGI was only minimal -- it happens to know about internal requests, and serves up content via a WSGI application. But more generally it's just about serializing and deserializing HTTP requests and responses, not unlike FormEncode.

There's some simple examples; basic client usage looks like:

from httpencode import GET
data = GET('http://slashdot.org', output='lxml')
all_ids = [el.attrib['id'] for el in data.xpath('//*[@id]')]

I.e., you give the output type (current supported are lxml, etree, cgi.FieldStorage and BeautifulSoup and python), and it does its best to coerce the output from the page to that type. As you can see, several of these convert XML and/or HTML, and the library doesn't assume there is only one suitable Python data type for this. python refers to basic Python data structures -- right now only json produces such structures (which aren't really a class of anything).

There's still a lot I want to do with it -- probably move to httplib2 and maybe like httplib2 use a class that is constructed with any app-specific options (like a default encoding). And I have to implement insecure formats (like Pickle) with the necessary options, and somehow figure out how to keep the function signatures under control.

Read: WSGIRemote now HTTPEncode

Topic: Erlang in Print (almost) Previous Topic   Next Topic Topic: Test driven development in Python

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use