| |
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <html><head><title>Python: module atom.service</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="atom.html"><font color="#ffffff">atom</font></a>.service</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/atom/service.py">/usr/local/google/home/afshar/src/external-gdata-release/google3/src/atom/service.py</a></font></td></tr></table> |
| <p><tt><a href="#AtomService">AtomService</a> provides CRUD ops. in line with the Atom Publishing Protocol.<br> |
| <br> |
| <a href="#AtomService">AtomService</a>: Encapsulates the ability to perform insert, update and delete<br> |
| operations with the Atom Publishing Protocol on which GData is<br> |
| based. An instance can perform query, insertion, deletion, and<br> |
| update.<br> |
| <br> |
| HttpRequest: Function that performs a GET, POST, PUT, or DELETE HTTP request<br> |
| to the specified end point. An <a href="#AtomService">AtomService</a> <a href="__builtin__.html#object">object</a> or a subclass can be<br> |
| used to specify information about the request.</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="xml.etree.cElementTree.html">xml.etree.cElementTree</a><br> |
| <a href="atom.html">atom</a><br> |
| <a href="base64.html">base64</a><br> |
| </td><td width="25%" valign=top><a href="httplib.html">httplib</a><br> |
| <a href="os.html">os</a><br> |
| <a href="re.html">re</a><br> |
| </td><td width="25%" valign=top><a href="socket.html">socket</a><br> |
| <a href="urllib.html">urllib</a><br> |
| <a href="warnings.html">warnings</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="atom.service.html#AtomService">AtomService</a> |
| </font></dt></dl> |
| </dd> |
| <dt><font face="helvetica, arial"><a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a>(<a href="__builtin__.html#object">__builtin__.object</a>) |
| </font></dt><dd> |
| <dl> |
| <dt><font face="helvetica, arial"><a href="atom.service.html#BasicAuthToken">BasicAuthToken</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="AtomService">class <strong>AtomService</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>Performs Atom Publishing Protocol CRUD operations.<br> |
| <br> |
| The <a href="#AtomService">AtomService</a> contains methods to perform HTTP CRUD operations.<br> </tt></td></tr> |
| <tr><td> </td> |
| <td width="100%">Methods defined here:<br> |
| <dl><dt><a name="AtomService-Delete"><strong>Delete</strong></a>(self, uri, extra_headers<font color="#909090">=None</font>, url_params<font color="#909090">=None</font>, escape_params<font color="#909090">=True</font>)</dt><dd><tt>Deletes the entry at the given URI.<br> |
| <br> |
| Args:<br> |
| uri: string The URI of the entry to be deleted. Example: <br> |
| '/base/feeds/items/ITEM-ID'<br> |
| extra_headers: dict (optional) HTTP headers which are to be included.<br> |
| The client automatically sets the Content-Type and<br> |
| Authorization headers.<br> |
| url_params: dict (optional) Additional URL parameters to be included<br> |
| in the URI. These are translated into query arguments<br> |
| in the form '&dict_key=value&...'.<br> |
| Example: {'max-results': '250'} becomes &max-results=250<br> |
| escape_params: boolean (optional) If false, the calling code has already<br> |
| ensured that the query will form a valid URL (all<br> |
| reserved characters have been escaped). If true, this<br> |
| method will escape the query and any URL parameters<br> |
| provided.<br> |
| <br> |
| Returns:<br> |
| httplib.HTTPResponse Server's response to the DELETE request.</tt></dd></dl> |
| |
| <dl><dt><a name="AtomService-Get"><strong>Get</strong></a>(self, uri, extra_headers<font color="#909090">=None</font>, url_params<font color="#909090">=None</font>, escape_params<font color="#909090">=True</font>)</dt><dd><tt>Query the APP server with the given URI<br> |
| <br> |
| The uri is the portion of the URI after the server value <br> |
| (server example: 'www.google.com').<br> |
| <br> |
| Example use:<br> |
| To perform a query against Google Base, set the server to <br> |
| 'base.google.com' and set the uri to '/base/feeds/...', where ... is <br> |
| your query. For example, to find snippets for all digital cameras uri <br> |
| should be set to: '/base/feeds/snippets?bq=digital+camera'<br> |
| <br> |
| Args:<br> |
| uri: string The query in the form of a URI. Example:<br> |
| '/base/feeds/snippets?bq=digital+camera'.<br> |
| extra_headers: dicty (optional) Extra HTTP headers to be included<br> |
| in the GET request. These headers are in addition to <br> |
| those stored in the client's additional_headers property.<br> |
| The client automatically sets the Content-Type and <br> |
| Authorization headers.<br> |
| url_params: dict (optional) Additional URL parameters to be included<br> |
| in the query. These are translated into query arguments<br> |
| in the form '&dict_key=value&...'.<br> |
| Example: {'max-results': '250'} becomes &max-results=250<br> |
| escape_params: boolean (optional) If false, the calling code has already<br> |
| ensured that the query will form a valid URL (all<br> |
| reserved characters have been escaped). If true, this<br> |
| method will escape the query and any URL parameters<br> |
| provided.<br> |
| <br> |
| Returns:<br> |
| httplib.HTTPResponse The server's response to the GET request.</tt></dd></dl> |
| |
| <dl><dt><a name="AtomService-Post"><strong>Post</strong></a>(self, 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>Insert data into an APP server at the given URI.<br> |
| <br> |
| Args:<br> |
| data: string, ElementTree._Element, or something with a __str__ method <br> |
| The XML to be sent to the uri. <br> |
| uri: string The location (feed) to which the data should be inserted. <br> |
| Example: '/base/feeds/items'. <br> |
| extra_headers: dict (optional) HTTP headers which are to be included. <br> |
| The client automatically sets the Content-Type,<br> |
| Authorization, and Content-Length headers.<br> |
| url_params: dict (optional) Additional URL parameters to be included<br> |
| in the URI. These are translated into query arguments<br> |
| in the form '&dict_key=value&...'.<br> |
| Example: {'max-results': '250'} becomes &max-results=250<br> |
| escape_params: boolean (optional) If false, the calling code has already<br> |
| ensured that the query will form a valid URL (all<br> |
| reserved characters have been escaped). If true, this<br> |
| method will escape the query and any URL parameters<br> |
| provided.<br> |
| <br> |
| Returns:<br> |
| httplib.HTTPResponse Server's response to the POST request.</tt></dd></dl> |
| |
| <dl><dt><a name="AtomService-Put"><strong>Put</strong></a>(self, 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>Updates an entry at the given URI.<br> |
| <br> |
| Args:<br> |
| data: string, ElementTree._Element, or xml_wrapper.ElementWrapper The <br> |
| XML containing the updated data.<br> |
| uri: string A URI indicating entry to which the update will be applied.<br> |
| Example: '/base/feeds/items/ITEM-ID'<br> |
| extra_headers: dict (optional) HTTP headers which are to be included.<br> |
| The client automatically sets the Content-Type,<br> |
| Authorization, and Content-Length headers.<br> |
| url_params: dict (optional) Additional URL parameters to be included<br> |
| in the URI. These are translated into query arguments<br> |
| in the form '&dict_key=value&...'.<br> |
| Example: {'max-results': '250'} becomes &max-results=250<br> |
| escape_params: boolean (optional) If false, the calling code has already<br> |
| ensured that the query will form a valid URL (all<br> |
| reserved characters have been escaped). If true, this<br> |
| method will escape the query and any URL parameters<br> |
| provided.<br> |
| <br> |
| Returns:<br> |
| httplib.HTTPResponse Server's response to the PUT request.</tt></dd></dl> |
| |
| <dl><dt><a name="AtomService-UseBasicAuth"><strong>UseBasicAuth</strong></a>(self, username, password, for_proxy<font color="#909090">=False</font>)</dt><dd><tt>Sets an Authenticaiton: Basic HTTP header containing plaintext.<br> |
| <br> |
| Deprecated, use use_basic_auth instead.<br> |
| <br> |
| The username and password are base64 encoded and added to an HTTP header<br> |
| which will be included in each request. Note that your username and <br> |
| password are sent in plaintext.<br> |
| <br> |
| Args:<br> |
| username: str<br> |
| password: str</tt></dd></dl> |
| |
| <dl><dt><a name="AtomService-__init__"><strong>__init__</strong></a>(*args, **kwargs)</dt><dd><tt># The deprecated_function wraps the actual call to f.</tt></dd></dl> |
| |
| <dl><dt><a name="AtomService-request"><strong>request</strong></a>(*args, **kwargs)</dt><dd><tt># The deprecated_function wraps the actual call to f.</tt></dd></dl> |
| |
| <dl><dt><a name="AtomService-use_basic_auth"><strong>use_basic_auth</strong></a>(self, username, password, scopes<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> |
| <dl><dt><strong>debug</strong></dt> |
| <dd><tt>If True, HTTP debug information is printed.</tt></dd> |
| </dl> |
| <dl><dt><strong>override_token</strong></dt> |
| </dl> |
| <hr> |
| Data and other attributes defined here:<br> |
| <dl><dt><strong>auto_set_current_token</strong> = True</dl> |
| |
| <dl><dt><strong>auto_store_tokens</strong> = True</dl> |
| |
| <dl><dt><strong>current_token</strong> = None</dl> |
| |
| <dl><dt><strong>port</strong> = 80</dl> |
| |
| <dl><dt><strong>ssl</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="BasicAuthToken">class <strong>BasicAuthToken</strong></a>(<a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</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="atom.service.html#BasicAuthToken">BasicAuthToken</a></dd> |
| <dd><a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</a></dd> |
| <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> |
| </dl> |
| <hr> |
| Methods defined here:<br> |
| <dl><dt><a name="BasicAuthToken-__init__"><strong>__init__</strong></a>(self, auth_header, scopes<font color="#909090">=None</font>)</dt><dd><tt>Creates a token used to add Basic Auth headers to HTTP requests.<br> |
| <br> |
| Args:<br> |
| auth_header: str The value for the Authorization header.<br> |
| scopes: list of str or atom.url.Url specifying the beginnings of URLs<br> |
| for which this token can be used. For example, if scopes contains<br> |
| '<a href="http://example.com/foo">http://example.com/foo</a>', then this token can be used for a request to<br> |
| '<a href="http://example.com/foo/bar">http://example.com/foo/bar</a>' but it cannot be used for a request to<br> |
| '<a href="http://example.com/baz">http://example.com/baz</a>'</tt></dd></dl> |
| |
| <dl><dt><a name="BasicAuthToken-__str__"><strong>__str__</strong></a>(self)</dt></dl> |
| |
| <dl><dt><a name="BasicAuthToken-perform_request"><strong>perform_request</strong></a>(self, http_client, operation, url, data<font color="#909090">=None</font>, headers<font color="#909090">=None</font>)</dt><dd><tt>Sets the Authorization header to the basic auth string.</tt></dd></dl> |
| |
| <dl><dt><a name="BasicAuthToken-valid_for_scope"><strong>valid_for_scope</strong></a>(self, url)</dt><dd><tt>Tells the caller if the token authorizes access to the desired URL.</tt></dd></dl> |
| |
| <hr> |
| Data descriptors inherited from <a href="atom.http_interface.html#GenericToken">atom.http_interface.GenericToken</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> |
| </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="-BuildUri"><strong>BuildUri</strong></a>(uri, url_params<font color="#909090">=None</font>, escape_params<font color="#909090">=True</font>)</dt><dd><tt>Converts a uri string and a collection of parameters into a URI.<br> |
| <br> |
| This function is deprcated, use atom.url.Url instead.<br> |
| <br> |
| Args:<br> |
| uri: string<br> |
| url_params: dict (optional)<br> |
| escape_params: boolean (optional)<br> |
| uri: string The start of the desired URI. This string can alrady contain<br> |
| URL parameters. Examples: '/base/feeds/snippets', <br> |
| '/base/feeds/snippets?bq=digital+camera'<br> |
| url_parameters: dict (optional) Additional URL parameters to be included<br> |
| in the query. These are translated into query arguments<br> |
| in the form '&dict_key=value&...'.<br> |
| Example: {'max-results': '250'} becomes &max-results=250<br> |
| escape_params: boolean (optional) If false, the calling code has already<br> |
| ensured that the query will form a valid URL (all<br> |
| reserved characters have been escaped). If true, this<br> |
| method will escape the query and any URL parameters<br> |
| provided.<br> |
| <br> |
| Returns:<br> |
| string The URI consisting of the escaped URL parameters appended to the<br> |
| initial uri string.</tt></dd></dl> |
| <dl><dt><a name="-CalculateDataLength"><strong>CalculateDataLength</strong></a>(data)</dt><dd><tt>Attempts to determine the length of the data to send. <br> |
| <br> |
| This method will respond with a length only if the data is a string or<br> |
| and ElementTree element.<br> |
| <br> |
| Args:<br> |
| data: <a href="__builtin__.html#object">object</a> If this is not a string or ElementTree element this funtion<br> |
| will return None.</tt></dd></dl> |
| <dl><dt><a name="-DictionaryToParamList"><strong>DictionaryToParamList</strong></a>(url_parameters, escape_params<font color="#909090">=True</font>)</dt><dd><tt>Convert a dictionary of URL arguments into a URL parameter string.<br> |
| <br> |
| This function is deprcated, use atom.url.Url instead.<br> |
| <br> |
| Args:<br> |
| url_parameters: The dictionaty of key-value pairs which will be converted<br> |
| into URL parameters. For example,<br> |
| {'dry-run': 'true', 'foo': 'bar'}<br> |
| will become ['dry-run=true', 'foo=bar'].<br> |
| <br> |
| Returns:<br> |
| A list which contains a string for each key-value pair. The strings are<br> |
| ready to be incorporated into a URL by using '&'.join([] + parameter_list)</tt></dd></dl> |
| <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 method is deprecated, use atom.http.HttpClient.request instead.<br> |
| <br> |
| Usage example, perform and HTTP GET on <a href="http://www.google.com/">http://www.google.com/</a>:<br> |
| import atom.service<br> |
| client = atom.service.<a href="#AtomService">AtomService</a>()<br> |
| http_response = client.Get('<a href="http://www.google.com/">http://www.google.com/</a>')<br> |
| or you could set the client.server to 'www.google.com' and use the <br> |
| following:<br> |
| client.server = 'www.google.com'<br> |
| http_response = client.Get('/')<br> |
| <br> |
| Args:<br> |
| service: atom.<a href="#AtomService">AtomService</a> <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: ElementTree, 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="-PrepareConnection"><strong>PrepareConnection</strong></a>(service, full_uri)</dt><dd><tt>Opens a connection to the server based on the full URI.<br> |
| <br> |
| This method is deprecated, instead use atom.http.HttpClient.request.<br> |
| <br> |
| Examines the target URI and the proxy settings, which are set as<br> |
| environment variables, to open a connection with the server. This<br> |
| connection is used to make an HTTP request.<br> |
| <br> |
| Args:<br> |
| service: atom.<a href="#AtomService">AtomService</a> or a subclass. It must have a server string which<br> |
| represents the server host to which the request should be made. It may also<br> |
| have a dictionary of additional_headers to send in the HTTP request.<br> |
| full_uri: str Which is the target relative (lacks protocol and host) or<br> |
| absolute URL to be opened. Example:<br> |
| 'https://www.google.com/accounts/ClientLogin' or<br> |
| 'base/feeds/snippets' where the server is set to www.google.com.<br> |
| <br> |
| Returns:<br> |
| A tuple containing the httplib.HTTPConnection and the full_uri for the<br> |
| request.</tt></dd></dl> |
| <dl><dt><a name="-ProcessUrl"><strong>ProcessUrl</strong></a>(service, url, for_proxy<font color="#909090">=False</font>)</dt><dd><tt>Processes a passed URL. If the URL does not begin with https?, then<br> |
| the default value for server is used<br> |
| <br> |
| This method is deprecated, use atom.url.parse_url instead.</tt></dd></dl> |
| <dl><dt><a name="-UseBasicAuth"><strong>UseBasicAuth</strong></a>(service, username, password, for_proxy<font color="#909090">=False</font>)</dt><dd><tt>Sets an Authenticaiton: Basic HTTP header containing plaintext.<br> |
| <br> |
| Deprecated, use <a href="#AtomService">AtomService</a>.use_basic_auth insread.<br> |
| <br> |
| The username and password are base64 encoded and added to an HTTP header<br> |
| which will be included in each request. Note that your username and <br> |
| password are sent in plaintext. The auth header is added to the <br> |
| additional_headers dictionary in the service <a href="__builtin__.html#object">object</a>.<br> |
| <br> |
| Args:<br> |
| service: atom.<a href="#AtomService">AtomService</a> or a subclass which has an <br> |
| additional_headers dict as a member.<br> |
| username: str<br> |
| password: str</tt></dd></dl> |
| <dl><dt><a name="-deprecation"><strong>deprecation</strong></a>(message)</dt></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> |