| |
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <html><head><title>Python: module gdata.urlfetch</title> |
| </head><body bgcolor="#f0f0f8"> |
| |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> |
| <tr bgcolor="#7799ee"> |
| <td valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="gdata.html"><font color="#ffffff">gdata</font></a>.urlfetch</strong></big></big></font></td |
| ><td align=right valign=bottom |
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/afshar/src/external-gdata-release/google3/src/gdata/urlfetch.py">/usr/local/google/home/afshar/src/external-gdata-release/google3/src/gdata/urlfetch.py</a></font></td></tr></table> |
| <p><tt>Provides HTTP functions for gdata.service to use on Google App Engine<br> |
| <br> |
| <a href="#AppEngineHttpClient">AppEngineHttpClient</a>: Provides an HTTP request method which uses App Engine's<br> |
| urlfetch API. Set the http_client member of a GDataService <a href="__builtin__.html#object">object</a> to an<br> |
| instance of an <a href="#AppEngineHttpClient">AppEngineHttpClient</a> to allow the gdata library to run on<br> |
| Google App Engine.<br> |
| <br> |
| run_on_appengine: Function which will modify an existing GDataService <a href="__builtin__.html#object">object</a><br> |
| to allow it to run on App Engine. It works by creating a new instance of<br> |
| the <a href="#AppEngineHttpClient">AppEngineHttpClient</a> and replacing the GDataService <a href="__builtin__.html#object">object</a>'s <br> |
| http_client.<br> |
| <br> |
| HttpRequest: Function that wraps google.appengine.api.urlfetch.Fetch in a <br> |
| common interface which is used by gdata.service.GDataService. In other <br> |
| words, this module can be used as the gdata service request handler so <br> |
| that all HTTP requests will be performed by the hosting Google App Engine<br> |
| server.</tt></p> |
| <p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#aa55cc"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> |
| |
| <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> |
| <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="StringIO.html">StringIO</a><br> |
| </td><td width="25%" valign=top><a href="atom.html">atom</a><br> |
| </td><td width="25%" valign=top><a href="google.appengine.api.urlfetch.html">google.appengine.api.urlfetch</a><br> |
| </td><td width="25%" valign=top></td></tr></table></td></tr></table><p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#ee77aa"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> |
| |
| <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> |
| <td width="100%"><dl> |
| <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> |
| </font></dt><dd> |
| <dl> |
| <dt><font face="helvetica, arial"><a href="gdata.urlfetch.html#HttpResponse">HttpResponse</a> |
| </font></dt></dl> |
| </dd> |
| <dt><font face="helvetica, arial"><a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>(<a href="__builtin__.html#object">__builtin__.object</a>) |
| </font></dt><dd> |
| <dl> |
| <dt><font face="helvetica, arial"><a href="gdata.urlfetch.html#AppEngineHttpClient">AppEngineHttpClient</a> |
| </font></dt></dl> |
| </dd> |
| </dl> |
| <p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#ffc8d8"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#000000" face="helvetica, arial"><a name="AppEngineHttpClient">class <strong>AppEngineHttpClient</strong></a>(<a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>)</font></td></tr> |
| |
| <tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td> |
| <td width="100%"><dl><dt>Method resolution order:</dt> |
| <dd><a href="gdata.urlfetch.html#AppEngineHttpClient">AppEngineHttpClient</a></dd> |
| <dd><a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a></dd> |
| <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> |
| </dl> |
| <hr> |
| Methods defined here:<br> |
| <dl><dt><a name="AppEngineHttpClient-__init__"><strong>__init__</strong></a>(self, headers<font color="#909090">=None</font>)</dt></dl> |
| |
| <dl><dt><a name="AppEngineHttpClient-request"><strong>request</strong></a>(self, operation, url, data<font color="#909090">=None</font>, headers<font color="#909090">=None</font>)</dt><dd><tt>Performs an HTTP call to the server, supports GET, POST, PUT, and<br> |
| DELETE.<br> |
| <br> |
| Usage example, perform and HTTP GET on <a href="http://www.google.com/">http://www.google.com/</a>:<br> |
| import atom.http<br> |
| client = atom.http.HttpClient()<br> |
| http_response = client.<a href="#AppEngineHttpClient-request">request</a>('GET', '<a href="http://www.google.com/">http://www.google.com/</a>')<br> |
| <br> |
| Args:<br> |
| operation: str The HTTP operation to be performed. This is usually one<br> |
| of 'GET', 'POST', 'PUT', or 'DELETE'<br> |
| data: filestream, list of parts, or other <a href="__builtin__.html#object">object</a> which can be converted<br> |
| to a string. Should be set to None when performing a GET or DELETE.<br> |
| If data is a file-like <a href="__builtin__.html#object">object</a> which can be read, this method will<br> |
| read a chunk of 100K bytes at a time and send them.<br> |
| If the data is a list of parts to be sent, each part will be<br> |
| evaluated and sent.<br> |
| url: The full URL to which the request should be sent. Can be a string<br> |
| or atom.url.Url.<br> |
| headers: dict of strings. HTTP headers which should be sent<br> |
| in the request.</tt></dd></dl> |
| |
| <hr> |
| Methods inherited from <a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>:<br> |
| <dl><dt><a name="AppEngineHttpClient-delete"><strong>delete</strong></a>(self, url, headers<font color="#909090">=None</font>)</dt></dl> |
| |
| <dl><dt><a name="AppEngineHttpClient-get"><strong>get</strong></a>(self, url, headers<font color="#909090">=None</font>)</dt></dl> |
| |
| <dl><dt><a name="AppEngineHttpClient-post"><strong>post</strong></a>(self, url, data, headers<font color="#909090">=None</font>)</dt></dl> |
| |
| <dl><dt><a name="AppEngineHttpClient-put"><strong>put</strong></a>(self, url, data, headers<font color="#909090">=None</font>)</dt></dl> |
| |
| <hr> |
| Data descriptors inherited from <a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>:<br> |
| <dl><dt><strong>__dict__</strong></dt> |
| <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| </dl> |
| <dl><dt><strong>__weakref__</strong></dt> |
| <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| </dl> |
| <hr> |
| Data and other attributes inherited from <a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>:<br> |
| <dl><dt><strong>debug</strong> = False</dl> |
| |
| </td></tr></table> <p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#ffc8d8"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#000000" face="helvetica, arial"><a name="HttpResponse">class <strong>HttpResponse</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> |
| |
| <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| <td colspan=2><tt>Translates a urlfetch resoinse to look like an hhtplib resoinse.<br> |
| <br> |
| Used to allow the resoinse from HttpRequest to be usable by gdata.service<br> |
| methods.<br> </tt></td></tr> |
| <tr><td> </td> |
| <td width="100%">Methods defined here:<br> |
| <dl><dt><a name="HttpResponse-__init__"><strong>__init__</strong></a>(self, urlfetch_response)</dt></dl> |
| |
| <dl><dt><a name="HttpResponse-getheader"><strong>getheader</strong></a>(self, name)</dt></dl> |
| |
| <dl><dt><a name="HttpResponse-read"><strong>read</strong></a>(self, length<font color="#909090">=None</font>)</dt></dl> |
| |
| <hr> |
| Data descriptors defined here:<br> |
| <dl><dt><strong>__dict__</strong></dt> |
| <dd><tt>dictionary for instance variables (if defined)</tt></dd> |
| </dl> |
| <dl><dt><strong>__weakref__</strong></dt> |
| <dd><tt>list of weak references to the object (if defined)</tt></dd> |
| </dl> |
| </td></tr></table></td></tr></table><p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#eeaa77"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> |
| |
| <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> |
| <td width="100%"><dl><dt><a name="-HttpRequest"><strong>HttpRequest</strong></a>(service, operation, data, uri, extra_headers<font color="#909090">=None</font>, url_params<font color="#909090">=None</font>, escape_params<font color="#909090">=True</font>, content_type<font color="#909090">='application/atom+xml'</font>)</dt><dd><tt>Performs an HTTP call to the server, supports GET, POST, PUT, and DELETE.<br> |
| <br> |
| This function is deprecated, use <a href="#AppEngineHttpClient">AppEngineHttpClient</a>.request instead.<br> |
| <br> |
| To use this module with gdata.service, you can set this module to be the<br> |
| http_request_handler so that HTTP requests use Google App Engine's urlfetch.<br> |
| import gdata.service<br> |
| import gdata.urlfetch<br> |
| gdata.service.http_request_handler = gdata.urlfetch<br> |
| <br> |
| Args:<br> |
| service: atom.AtomService <a href="__builtin__.html#object">object</a> which contains some of the parameters<br> |
| needed to make the request. The following members are used to<br> |
| construct the HTTP call: server (str), additional_headers (dict),<br> |
| port (int), and ssl (bool).<br> |
| operation: str The HTTP operation to be performed. This is usually one of<br> |
| 'GET', 'POST', 'PUT', or 'DELETE'<br> |
| data: filestream, list of parts, or other <a href="__builtin__.html#object">object</a> which can be<br> |
| converted to a string.<br> |
| Should be set to None when performing a GET or PUT.<br> |
| If data is a file-like <a href="__builtin__.html#object">object</a> which can be read, this method will read<br> |
| a chunk of 100K bytes at a time and send them.<br> |
| If the data is a list of parts to be sent, each part will be evaluated<br> |
| and sent.<br> |
| uri: The beginning of the URL to which the request should be sent.<br> |
| Examples: '/', '/base/feeds/snippets',<br> |
| '/m8/feeds/contacts/default/base'<br> |
| extra_headers: dict of strings. HTTP headers which should be sent<br> |
| in the request. These headers are in addition to those stored in<br> |
| service.additional_headers.<br> |
| url_params: dict of strings. Key value pairs to be added to the URL as<br> |
| URL parameters. For example {'foo':'bar', 'test':'param'} will<br> |
| become ?foo=bar&test=param.<br> |
| escape_params: bool default True. If true, the keys and values in<br> |
| url_params will be URL escaped when the form is constructed<br> |
| (Special characters converted to %XX form.)<br> |
| content_type: str The MIME type for the data being sent. Defaults to<br> |
| 'application/atom+xml', this is only used if data is set.</tt></dd></dl> |
| <dl><dt><a name="-run_on_appengine"><strong>run_on_appengine</strong></a>(gdata_service)</dt><dd><tt>Modifies a GDataService <a href="__builtin__.html#object">object</a> to allow it to run on App Engine.<br> |
| <br> |
| Args:<br> |
| gdata_service: An instance of AtomService, GDataService, or any<br> |
| of their subclasses which has an http_client member.</tt></dd></dl> |
| </td></tr></table><p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#55aa55"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> |
| |
| <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> |
| <td width="100%"><strong>__author__</strong> = 'api.jscudder (Jeff Scudder)'</td></tr></table><p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#7799ee"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr> |
| |
| <tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td> |
| <td width="100%">api.jscudder (Jeff Scudder)</td></tr></table> |
| </body></html> |