| |
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <html><head><title>Python: module gdata.books.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="gdata.html"><font color="#ffffff">gdata</font></a>.<a href="gdata.books.html"><font color="#ffffff">books</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/gdata/books/service.py">/usr/local/google/home/afshar/src/external-gdata-release/google3/src/gdata/books/service.py</a></font></td></tr></table> |
| <p><tt>Extend gdata.service.<a href="gdata.service.html#GDataService">GDataService</a> to support authenticated CRUD ops on <br> |
| Books API<br> |
| <br> |
| <a href="http://code.google.com/apis/books/docs/getting-started.html">http://code.google.com/apis/books/docs/getting-started.html</a><br> |
| <a href="http://code.google.com/apis/books/docs/gdata/developers_guide_protocol.html">http://code.google.com/apis/books/docs/gdata/developers_guide_protocol.html</a><br> |
| <br> |
| TODO: (here and __init__)<br> |
| * search based on label, review, or other annotations (possible?)<br> |
| * edit (specifically, Put requests) seem to fail effect a change<br> |
| <br> |
| Problems With API:<br> |
| * Adding a book with a review to the library adds a note, not a review.<br> |
| This does not get included in the returned item. You see this by<br> |
| looking at My Library through the website.<br> |
| * Editing a review never edits a review (unless it is freshly added, but <br> |
| see above). More generally,<br> |
| * a Put request with changed annotations (label/rating/review) does NOT<br> |
| change the data. Note: Put requests only work on the href from <br> |
| GetEditLink (as per the spec). Do not try to PUT to the annotate or <br> |
| library feeds, this will cause a 400 Invalid URI Bad Request response.<br> |
| Attempting to Post to one of the feeds with the updated annotations<br> |
| does not update them. See the following for (hopefully) a follow up:<br> |
| google.com/support/forum/p/booksearch-apis/thread?tid=27fd7f68de438fc8<br> |
| * Attempts to workaround the edit problem continue to fail. For example,<br> |
| removing the item, editing the data, readding the item, gives us only<br> |
| our originally added data (annotations). This occurs even if we<br> |
| completely shut python down, refetch the book from the public feed,<br> |
| and re-add it. There is some kind of persistence going on that I<br> |
| cannot change. This is likely due to the annotations being cached in<br> |
| the annotation feed and the inability to edit (see Put, above)<br> |
| * GetAnnotationLink has www.books.... as the server, but hitting www...<br> |
| results in a bad URI error.<br> |
| * Spec indicates there may be multiple labels, but there does not seem<br> |
| to be a way to get the server to accept multiple labels, nor does the<br> |
| web interface have an obvious way to have multiple labels. Multiple <br> |
| labels are never returned.</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="gdata.books.html">gdata.books</a><br> |
| </td><td width="25%" valign=top><a href="gdata.html">gdata</a><br> |
| </td><td width="25%" valign=top></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="gdata.service.html#GDataService">gdata.service.GDataService</a>(<a href="atom.service.html#AtomService">atom.service.AtomService</a>) |
| </font></dt><dd> |
| <dl> |
| <dt><font face="helvetica, arial"><a href="gdata.books.service.html#BookService">BookService</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="BookService">class <strong>BookService</strong></a>(<a href="gdata.service.html#GDataService">gdata.service.GDataService</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.books.service.html#BookService">BookService</a></dd> |
| <dd><a href="gdata.service.html#GDataService">gdata.service.GDataService</a></dd> |
| <dd><a href="atom.service.html#AtomService">atom.service.AtomService</a></dd> |
| <dd><a href="__builtin__.html#object">__builtin__.object</a></dd> |
| </dl> |
| <hr> |
| Methods defined here:<br> |
| <dl><dt><a name="BookService-__init__"><strong>__init__</strong></a>(self, email<font color="#909090">=None</font>, password<font color="#909090">=None</font>, source<font color="#909090">=None</font>, server<font color="#909090">='books.google.com'</font>, account_type<font color="#909090">='HOSTED_OR_GOOGLE'</font>, exception_handlers<font color="#909090">=()</font>, **kwargs)</dt><dd><tt>source should be of form 'ProgramCompany - ProgramName - Version'</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-add_annotation"><strong>add_annotation</strong></a>(self, item)</dt><dd><tt>Add the item, either an XML string or books.Book instance, to the <br> |
| user's annotation feed.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-add_item_to_library"><strong>add_item_to_library</strong></a>(self, item)</dt><dd><tt>Add the item, either an XML string or books.Book instance, to the <br> |
| user's library feed</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-edit_annotation"><strong>edit_annotation</strong></a>(self, item)</dt><dd><tt>Send an edited item, a books.Book instance, to the user's annotation <br> |
| feed. Note that whereas extra annotations in add_annotations, minus <br> |
| ratings which are immutable once set, are simply added to the item in <br> |
| the annotation feed, if an annotation has been removed from the item, <br> |
| sending an edit request will remove that annotation. This should not <br> |
| happen with add_annotation.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-get_annotations"><strong>get_annotations</strong></a>(self, id<font color="#909090">='me'</font>, start_index<font color="#909090">='1'</font>, max_results<font color="#909090">='100'</font>, min_viewability<font color="#909090">='none'</font>, converter<font color="#909090">=<bound method type.FromString of <class 'gdata.books.BookFeed'>></font>)</dt><dd><tt>Like get_library, but for the annotation feed</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-get_by_google_id"><strong>get_by_google_id</strong></a>(self, id)</dt></dl> |
| |
| <dl><dt><a name="BookService-get_library"><strong>get_library</strong></a>(self, id<font color="#909090">='me'</font>, feed<font color="#909090">='/books/feeds/users/%s/collections/library/volumes'</font>, start_index<font color="#909090">='1'</font>, max_results<font color="#909090">='100'</font>, min_viewability<font color="#909090">='none'</font>, converter<font color="#909090">=<bound method type.FromString of <class 'gdata.books.BookFeed'>></font>)</dt><dd><tt>Return a generator object that will return gbook.Book instances until<br> |
| the search feed no longer returns an item from the GetNextLink method.<br> |
| Thus max_results is not the maximum number of items that will be<br> |
| returned, but rather the number of items per page of searches. This has<br> |
| been set high to reduce the required number of network requests.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-remove_item_from_library"><strong>remove_item_from_library</strong></a>(self, item)</dt><dd><tt>Remove the item, a books.Book instance, from the authenticated user's <br> |
| library feed. Using an item retrieved from a public search will fail.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-search"><strong>search</strong></a>(self, q, start_index<font color="#909090">='1'</font>, max_results<font color="#909090">='10'</font>, min_viewability<font color="#909090">='none'</font>, feed<font color="#909090">='/books/feeds/volumes'</font>, converter<font color="#909090">=<bound method type.FromString of <class 'gdata.books.BookFeed'>></font>)</dt><dd><tt>Query the Public search feed. q is either a search string or a<br> |
| gdata.service.Query instance with a query set.<br> |
| <br> |
| min_viewability must be "none", "partial", or "full".<br> |
| <br> |
| If you change the feed to a single item feed, note that you will <br> |
| probably need to change the converter to be Book.FromString</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-search_annotations"><strong>search_annotations</strong></a>(self, q, id<font color="#909090">='me'</font>, **kwargs)</dt><dd><tt>Like search, but in an annotation feed. Default is the authenticated<br> |
| user's feed. Change by setting id.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-search_annotations_by_keyword"><strong>search_annotations_by_keyword</strong></a>(self, id<font color="#909090">='me'</font>, **kwargs)</dt><dd><tt>Hybrid of search_by_keyword and search_annotations</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-search_by_keyword"><strong>search_by_keyword</strong></a>(self, q<font color="#909090">=''</font>, feed<font color="#909090">='/books/feeds/volumes'</font>, start_index<font color="#909090">='1'</font>, max_results<font color="#909090">='10'</font>, min_viewability<font color="#909090">='none'</font>, **kwargs)</dt><dd><tt>Query the Public Search Feed by keyword. Non-keyword strings can be<br> |
| set in q. This is quite fragile. Is there a function somewhere in<br> |
| the Google library that will parse a query the same way that Google<br> |
| does?<br> |
| <br> |
| Legal Identifiers are listed below and correspond to their meaning<br> |
| at <a href="http://books.google.com/advanced_book_search">http://books.google.com/advanced_book_search</a>:<br> |
| all_words <br> |
| exact_phrase <br> |
| at_least_one <br> |
| without_words <br> |
| title<br> |
| author<br> |
| publisher<br> |
| subject<br> |
| isbn<br> |
| lccn<br> |
| oclc<br> |
| seemingly unsupported:<br> |
| publication_date: a sequence of two, two tuples:<br> |
| ((min_month,min_year),(max_month,max_year))<br> |
| where month is one/two digit month, year is 4 digit, eg:<br> |
| (('1','2000'),('10','2003')). Lower bound is inclusive,<br> |
| upper bound is exclusive</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-search_library"><strong>search_library</strong></a>(self, q, id<font color="#909090">='me'</font>, **kwargs)</dt><dd><tt>Like search, but in a library feed. Default is the authenticated<br> |
| user's feed. Change by setting id.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-search_library_by_keyword"><strong>search_library_by_keyword</strong></a>(self, id<font color="#909090">='me'</font>, **kwargs)</dt><dd><tt>Hybrid of search_by_keyword and search_library</tt></dd></dl> |
| |
| <hr> |
| Methods inherited from <a href="gdata.service.html#GDataService">gdata.service.GDataService</a>:<br> |
| <dl><dt><a name="BookService-AuthSubTokenInfo"><strong>AuthSubTokenInfo</strong></a>(self)</dt><dd><tt>Fetches the AuthSub token's metadata from the server.<br> |
| <br> |
| Raises:<br> |
| NonAuthSubToken if the user's auth token is not an AuthSub token</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-ClientLogin"><strong>ClientLogin</strong></a>(self, username, password, account_type<font color="#909090">=None</font>, service<font color="#909090">=None</font>, auth_service_url<font color="#909090">=None</font>, source<font color="#909090">=None</font>, captcha_token<font color="#909090">=None</font>, captcha_response<font color="#909090">=None</font>)</dt><dd><tt>Convenience method for authenticating using ProgrammaticLogin. <br> |
| <br> |
| Sets values for email, password, and other optional members.<br> |
| <br> |
| Args:<br> |
| username:<br> |
| password:<br> |
| account_type: string (optional)<br> |
| service: string (optional)<br> |
| auth_service_url: string (optional)<br> |
| captcha_token: string (optional)<br> |
| captcha_response: string (optional)</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-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>, redirects_remaining<font color="#909090">=4</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> |
| True if the entry was deleted.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-FetchOAuthRequestToken"><strong>FetchOAuthRequestToken</strong></a>(self, scopes<font color="#909090">=None</font>, extra_parameters<font color="#909090">=None</font>, request_url<font color="#909090">='https://www.google.com/accounts/OAuthGetRequestToken'</font>, oauth_callback<font color="#909090">=None</font>)</dt><dd><tt>Fetches and sets the OAuth request token and returns it.<br> |
| <br> |
| Args:<br> |
| scopes: string or list of string base URL(s) of the service(s) to be<br> |
| accessed. If None, then this method tries to determine the<br> |
| scope(s) from the current service.<br> |
| extra_parameters: dict (optional) key-value pairs as any additional<br> |
| parameters to be included in the URL and signature while making a<br> |
| request for fetching an OAuth request token. All the OAuth parameters<br> |
| are added by default. But if provided through this argument, any<br> |
| default parameters will be overwritten. For e.g. a default parameter<br> |
| oauth_version 1.0 can be overwritten if<br> |
| extra_parameters = {'oauth_version': '2.0'}<br> |
| request_url: Request token URL. The default is<br> |
| 'https://www.google.com/accounts/OAuthGetRequestToken'.<br> |
| oauth_callback: str (optional) If set, it is assume the client is using<br> |
| the OAuth v1.0a protocol where the callback url is sent in the<br> |
| request token step. If the oauth_callback is also set in<br> |
| extra_params, this value will override that one.<br> |
| <br> |
| Returns:<br> |
| The fetched request token as a gdata.auth.OAuthToken object.<br> |
| <br> |
| Raises:<br> |
| FetchingOAuthRequestTokenFailed if the server responded to the request<br> |
| with an error.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GenerateAuthSubURL"><strong>GenerateAuthSubURL</strong></a>(self, next, scope, secure<font color="#909090">=False</font>, session<font color="#909090">=True</font>, domain<font color="#909090">='default'</font>)</dt><dd><tt>Generate a URL at which the user will login and be redirected back.<br> |
| <br> |
| Users enter their credentials on a Google login page and a token is sent<br> |
| to the URL specified in next. See documentation for AuthSub login at:<br> |
| <a href="http://code.google.com/apis/accounts/docs/AuthSub.html">http://code.google.com/apis/accounts/docs/AuthSub.html</a><br> |
| <br> |
| Args:<br> |
| next: string The URL user will be sent to after logging in.<br> |
| scope: string or list of strings. The URLs of the services to be <br> |
| accessed.<br> |
| secure: boolean (optional) Determines whether or not the issued token<br> |
| is a secure token.<br> |
| session: boolean (optional) Determines whether or not the issued token<br> |
| can be upgraded to a session token.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GenerateOAuthAuthorizationURL"><strong>GenerateOAuthAuthorizationURL</strong></a>(self, request_token<font color="#909090">=None</font>, callback_url<font color="#909090">=None</font>, extra_params<font color="#909090">=None</font>, include_scopes_in_callback<font color="#909090">=False</font>, scopes_param_prefix<font color="#909090">='oauth_token_scope'</font>, request_url<font color="#909090">='https://www.google.com/accounts/OAuthAuthorizeToken'</font>)</dt><dd><tt>Generates URL at which user will login to authorize the request token.<br> |
| <br> |
| Args:<br> |
| request_token: gdata.auth.OAuthToken (optional) OAuth request token.<br> |
| If not specified, then the current token will be used if it is of<br> |
| type <gdata.auth.OAuthToken>, else it is found by looking in the<br> |
| token_store by looking for a token for the current scope. <br> |
| callback_url: string (optional) The URL user will be sent to after<br> |
| logging in and granting access.<br> |
| extra_params: dict (optional) Additional parameters to be sent.<br> |
| include_scopes_in_callback: Boolean (default=False) if set to True, and<br> |
| if 'callback_url' is present, the 'callback_url' will be modified to<br> |
| include the scope(s) from the request token as a URL parameter. The<br> |
| key for the 'callback' URL's scope parameter will be<br> |
| OAUTH_SCOPE_URL_PARAM_NAME. The benefit of including the scope URL as<br> |
| a parameter to the 'callback' URL, is that the page which receives<br> |
| the OAuth token will be able to tell which URLs the token grants<br> |
| access to.<br> |
| scopes_param_prefix: string (default='oauth_token_scope') The URL<br> |
| parameter key which maps to the list of valid scopes for the token.<br> |
| This URL parameter will be included in the callback URL along with<br> |
| the scopes of the token as value if include_scopes_in_callback=True.<br> |
| request_url: Authorization URL. The default is<br> |
| 'https://www.google.com/accounts/OAuthAuthorizeToken'.<br> |
| Returns:<br> |
| A string URL at which the user is required to login.<br> |
| <br> |
| Raises:<br> |
| NonOAuthToken if the user's request token is not an OAuth token or if a<br> |
| request token was not available.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-Get"><strong>Get</strong></a>(self, uri, extra_headers<font color="#909090">=None</font>, redirects_remaining<font color="#909090">=4</font>, encoding<font color="#909090">='UTF-8'</font>, converter<font color="#909090">=None</font>)</dt><dd><tt>Query the GData API with the given URI<br> |
| <br> |
| The uri is the portion of the URI after the server value <br> |
| (ex: www.google.com).<br> |
| <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: dictionary (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> |
| redirects_remaining: int (optional) Tracks the number of additional<br> |
| redirects this method will allow. If the service object receives<br> |
| a redirect and remaining is 0, it will not follow the redirect. <br> |
| This was added to avoid infinite redirect loops.<br> |
| encoding: string (optional) The character encoding for the server's<br> |
| response. Default is UTF-8<br> |
| converter: func (optional) A function which will transform<br> |
| the server's results before it is returned. Example: use <br> |
| GDataFeedFromString to parse the server response as if it<br> |
| were a GDataFeed.<br> |
| <br> |
| Returns:<br> |
| If there is no ResultsTransformer specified in the call, a GDataFeed <br> |
| or GDataEntry depending on which is sent from the server. If the <br> |
| response is niether a feed or entry and there is no ResultsTransformer,<br> |
| return a string. If there is a ResultsTransformer, the returned value <br> |
| will be that of the ResultsTransformer function.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GetAuthSubToken"><strong>GetAuthSubToken</strong></a>(self)</dt><dd><tt>Returns the AuthSub token as a string.<br> |
| <br> |
| If the token is an gdta.auth.AuthSubToken, the Authorization Label<br> |
| ("AuthSub token") is removed.<br> |
| <br> |
| This method examines the current_token to see if it is an AuthSubToken<br> |
| or SecureAuthSubToken. If not, it searches the token_store for a token<br> |
| which matches the current scope.<br> |
| <br> |
| The current scope is determined by the service name string member.<br> |
| <br> |
| Returns:<br> |
| If the current_token is set to an AuthSubToken/SecureAuthSubToken,<br> |
| return the token string. If there is no current_token, a token string<br> |
| for a token which matches the service object's default scope is returned.<br> |
| If there are no tokens valid for the scope, returns None.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GetClientLoginToken"><strong>GetClientLoginToken</strong></a>(self)</dt><dd><tt>Returns the token string for the current token or a token matching the <br> |
| service scope.<br> |
| <br> |
| If the current_token is a ClientLoginToken, the token string for <br> |
| the current token is returned. If the current_token is not set, this method<br> |
| searches for a token in the token_store which is valid for the service <br> |
| object's current scope.<br> |
| <br> |
| The current scope is determined by the service name string member.<br> |
| The token string is the end of the Authorization header, it doesn not<br> |
| include the ClientLogin label.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GetEntry"><strong>GetEntry</strong></a>(self, uri, extra_headers<font color="#909090">=None</font>)</dt><dd><tt>Query the GData API with the given URI and receive an Entry.<br> |
| <br> |
| See also documentation for gdata.service.Get<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: dictionary (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> |
| <br> |
| Returns:<br> |
| A GDataEntry built from the XML in the server's response.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GetFeed"><strong>GetFeed</strong></a>(self, uri, extra_headers<font color="#909090">=None</font>, converter<font color="#909090">=<function GDataFeedFromString></font>)</dt><dd><tt>Query the GData API with the given URI and receive a Feed.<br> |
| <br> |
| See also documentation for gdata.service.Get<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: dictionary (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> |
| <br> |
| Returns:<br> |
| A GDataFeed built from the XML in the server's response.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GetGeneratorFromLinkFinder"><strong>GetGeneratorFromLinkFinder</strong></a>(self, link_finder, func, num_retries<font color="#909090">=3</font>, delay<font color="#909090">=1</font>, backoff<font color="#909090">=2</font>)</dt><dd><tt>returns a generator for pagination</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GetMedia"><strong>GetMedia</strong></a>(self, uri, extra_headers<font color="#909090">=None</font>)</dt><dd><tt>Returns a MediaSource containing media and its metadata from the given<br> |
| URI string.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GetNext"><strong>GetNext</strong></a>(self, feed)</dt><dd><tt>Requests the next 'page' of results in the feed.<br> |
| <br> |
| This method uses the feed's next link to request an additional feed<br> |
| and uses the class of the feed to convert the results of the GET request.<br> |
| <br> |
| Args:<br> |
| feed: atom.Feed or a subclass. The feed should contain a next link and<br> |
| the type of the feed will be applied to the results from the <br> |
| server. The new feed which is returned will be of the same class<br> |
| as this feed which was passed in.<br> |
| <br> |
| Returns:<br> |
| A new feed representing the next set of results in the server's feed.<br> |
| The type of this feed will match that of the feed argument.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-GetOAuthInputParameters"><strong>GetOAuthInputParameters</strong></a>(self)</dt></dl> |
| |
| <dl><dt><a name="BookService-GetWithRetries"><strong>GetWithRetries</strong></a>(self, uri, extra_headers<font color="#909090">=None</font>, redirects_remaining<font color="#909090">=4</font>, encoding<font color="#909090">='UTF-8'</font>, converter<font color="#909090">=None</font>, num_retries<font color="#909090">=3</font>, delay<font color="#909090">=1</font>, backoff<font color="#909090">=2</font>, logger<font color="#909090">=None</font>)</dt><dd><tt>This is a wrapper method for Get with retrying capability.<br> |
| <br> |
| To avoid various errors while retrieving bulk entities by retrying<br> |
| specified times.<br> |
| <br> |
| Note this method relies on the time module and so may not be usable<br> |
| by default in Python2.2.<br> |
| <br> |
| Args:<br> |
| num_retries: Integer; the retry count.<br> |
| delay: Integer; the initial delay for retrying.<br> |
| backoff: Integer; how much the delay should lengthen after each failure.<br> |
| logger: An object which has a <a href="#BookService-debug">debug</a>(str) method to receive logging<br> |
| messages. Recommended that you pass in the logging module.<br> |
| Raises:<br> |
| ValueError if any of the parameters has an invalid value.<br> |
| RanOutOfTries on failure after number of retries.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-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>, redirects_remaining<font color="#909090">=4</font>, media_source<font color="#909090">=None</font>, converter<font color="#909090">=None</font>)</dt><dd><tt>Insert or update data into a GData service at the given URI.<br> |
| <br> |
| Args:<br> |
| data: string, ElementTree._Element, atom.Entry, or gdata.GDataEntry The<br> |
| 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> |
| media_source: MediaSource (optional) Container for the media to be sent<br> |
| along with the entry, if provided.<br> |
| converter: func (optional) A function which will be executed on the<br> |
| server's response. Often this is a function like<br> |
| GDataEntryFromString which will parse the body of the server's<br> |
| response and return a GDataEntry.<br> |
| <br> |
| Returns:<br> |
| If the post succeeded, this method will return a GDataFeed, GDataEntry,<br> |
| or the results of running converter on the server's result body (if<br> |
| converter was specified).</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-PostOrPut"><strong>PostOrPut</strong></a>(self, verb, data, uri, extra_headers<font color="#909090">=None</font>, url_params<font color="#909090">=None</font>, escape_params<font color="#909090">=True</font>, redirects_remaining<font color="#909090">=4</font>, media_source<font color="#909090">=None</font>, converter<font color="#909090">=None</font>)</dt><dd><tt>Insert data into a GData service at the given URI.<br> |
| <br> |
| Args:<br> |
| verb: string, either 'POST' or 'PUT'<br> |
| data: string, ElementTree._Element, atom.Entry, or gdata.GDataEntry The<br> |
| 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> |
| media_source: MediaSource (optional) Container for the media to be sent<br> |
| along with the entry, if provided.<br> |
| converter: func (optional) A function which will be executed on the <br> |
| server's response. Often this is a function like <br> |
| GDataEntryFromString which will parse the body of the server's <br> |
| response and return a GDataEntry.<br> |
| <br> |
| Returns:<br> |
| If the post succeeded, this method will return a GDataFeed, GDataEntry,<br> |
| or the results of running converter on the server's result body (if<br> |
| converter was specified).</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-ProgrammaticLogin"><strong>ProgrammaticLogin</strong></a>(self, captcha_token<font color="#909090">=None</font>, captcha_response<font color="#909090">=None</font>)</dt><dd><tt>Authenticates the user and sets the GData Auth token.<br> |
| <br> |
| Login retreives a temporary auth token which must be used with all<br> |
| requests to GData services. The auth token is stored in the GData client<br> |
| object.<br> |
| <br> |
| Login is also used to respond to a captcha challenge. If the user's login<br> |
| attempt failed with a CaptchaRequired error, the user can respond by<br> |
| calling Login with the captcha token and the answer to the challenge.<br> |
| <br> |
| Args:<br> |
| captcha_token: string (optional) The identifier for the captcha challenge<br> |
| which was presented to the user.<br> |
| captcha_response: string (optional) The user's answer to the captch <br> |
| challenge.<br> |
| <br> |
| Raises:<br> |
| CaptchaRequired if the login service will require a captcha response<br> |
| BadAuthentication if the login service rejected the username or password<br> |
| Error if the login service responded with a 403 different from the above</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-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>, redirects_remaining<font color="#909090">=3</font>, media_source<font color="#909090">=None</font>, converter<font color="#909090">=None</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> |
| converter: func (optional) A function which will be executed on the <br> |
| server's response. Often this is a function like <br> |
| GDataEntryFromString which will parse the body of the server's <br> |
| response and return a GDataEntry.<br> |
| <br> |
| Returns:<br> |
| If the put succeeded, this method will return a GDataFeed, GDataEntry,<br> |
| or the results of running converter on the server's result body (if<br> |
| converter was specified).</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-RevokeAuthSubToken"><strong>RevokeAuthSubToken</strong></a>(self)</dt><dd><tt>Revokes an existing AuthSub token.<br> |
| <br> |
| Raises:<br> |
| NonAuthSubToken if the user's auth token is not an AuthSub token</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-RevokeOAuthToken"><strong>RevokeOAuthToken</strong></a>(self, request_url<font color="#909090">='https://www.google.com/accounts/AuthSubRevokeToken'</font>)</dt><dd><tt>Revokes an existing OAuth token.<br> |
| <br> |
| request_url: Token revoke URL. The default is<br> |
| 'https://www.google.com/accounts/AuthSubRevokeToken'.<br> |
| Raises:<br> |
| NonOAuthToken if the user's auth token is not an OAuth token.<br> |
| RevokingOAuthTokenFailed if request for revoking an OAuth token failed.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-SetAuthSubToken"><strong>SetAuthSubToken</strong></a>(self, token, scopes<font color="#909090">=None</font>, rsa_key<font color="#909090">=None</font>)</dt><dd><tt>Sets the token sent in requests to an AuthSub token.<br> |
| <br> |
| Sets the current_token and attempts to add the token to the token_store.<br> |
| <br> |
| Only use this method if you have received a token from the AuthSub<br> |
| service. The auth token is set automatically when <a href="#BookService-UpgradeToSessionToken">UpgradeToSessionToken</a>()<br> |
| is used. See documentation for Google AuthSub here:<br> |
| <a href="http://code.google.com/apis/accounts/AuthForWebApps.html">http://code.google.com/apis/accounts/AuthForWebApps.html</a> <br> |
| <br> |
| Args:<br> |
| token: gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken or string<br> |
| The token returned by the AuthSub service. If the token is an<br> |
| AuthSubToken or SecureAuthSubToken, the scope information stored in<br> |
| the token is used. If the token is a string, the scopes parameter is<br> |
| used to determine the valid scopes.<br> |
| scopes: list of URLs for which the token is valid. This is only used<br> |
| if the token parameter is a string.<br> |
| rsa_key: string (optional) Private key required for RSA_SHA1 signature<br> |
| method. This parameter is necessary if the token is a string<br> |
| representing a secure token.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-SetClientLoginToken"><strong>SetClientLoginToken</strong></a>(self, token, scopes<font color="#909090">=None</font>)</dt><dd><tt>Sets the token sent in requests to a ClientLogin token.<br> |
| <br> |
| This method sets the current_token to a new ClientLoginToken and it <br> |
| also attempts to add the ClientLoginToken to the token_store.<br> |
| <br> |
| Only use this method if you have received a token from the ClientLogin<br> |
| service. The auth_token is set automatically when <a href="#BookService-ProgrammaticLogin">ProgrammaticLogin</a>()<br> |
| is used. See documentation for Google ClientLogin here:<br> |
| <a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html">http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html</a><br> |
| <br> |
| Args:<br> |
| token: string or instance of a ClientLoginToken.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-SetOAuthInputParameters"><strong>SetOAuthInputParameters</strong></a>(self, signature_method, consumer_key, consumer_secret<font color="#909090">=None</font>, rsa_key<font color="#909090">=None</font>, two_legged_oauth<font color="#909090">=False</font>, requestor_id<font color="#909090">=None</font>)</dt><dd><tt>Sets parameters required for using OAuth authentication mechanism.<br> |
| <br> |
| NOTE: Though consumer_secret and rsa_key are optional, either of the two<br> |
| is required depending on the value of the signature_method.<br> |
| <br> |
| Args:<br> |
| signature_method: class which provides implementation for strategy class<br> |
| oauth.oauth.OAuthSignatureMethod. Signature method to be used for<br> |
| signing each request. Valid implementations are provided as the<br> |
| constants defined by gdata.auth.OAuthSignatureMethod. Currently<br> |
| they are gdata.auth.OAuthSignatureMethod.RSA_SHA1 and<br> |
| gdata.auth.OAuthSignatureMethod.HMAC_SHA1<br> |
| consumer_key: string Domain identifying third_party web application.<br> |
| consumer_secret: string (optional) Secret generated during registration.<br> |
| Required only for HMAC_SHA1 signature method.<br> |
| rsa_key: string (optional) Private key required for RSA_SHA1 signature<br> |
| method.<br> |
| two_legged_oauth: boolean (optional) Enables two-legged OAuth process.<br> |
| requestor_id: string (optional) User email adress to make requests on<br> |
| their behalf. This parameter should only be set when two_legged_oauth<br> |
| is True.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-SetOAuthToken"><strong>SetOAuthToken</strong></a>(self, oauth_token)</dt><dd><tt>Attempts to set the current token and add it to the token store.<br> |
| <br> |
| The oauth_token can be any OAuth token i.e. unauthorized request token,<br> |
| authorized request token or access token.<br> |
| This method also attempts to add the token to the token store.<br> |
| Use this method any time you want the current token to point to the<br> |
| oauth_token passed. For e.g. call this method with the request token<br> |
| you receive from FetchOAuthRequestToken.<br> |
| <br> |
| Args:<br> |
| request_token: gdata.auth.OAuthToken OAuth request token.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-UpgradeToOAuthAccessToken"><strong>UpgradeToOAuthAccessToken</strong></a>(self, authorized_request_token<font color="#909090">=None</font>, request_url<font color="#909090">='https://www.google.com/accounts/OAuthGetAccessToken'</font>, oauth_version<font color="#909090">='1.0'</font>, oauth_verifier<font color="#909090">=None</font>)</dt><dd><tt>Upgrades the authorized request token to an access token and returns it<br> |
| <br> |
| Args:<br> |
| authorized_request_token: gdata.auth.OAuthToken (optional) OAuth request<br> |
| token. If not specified, then the current token will be used if it is<br> |
| of type <gdata.auth.OAuthToken>, else it is found by looking in the<br> |
| token_store by looking for a token for the current scope.<br> |
| request_url: Access token URL. The default is<br> |
| 'https://www.google.com/accounts/OAuthGetAccessToken'.<br> |
| oauth_version: str (default='1.0') oauth_version parameter. All other<br> |
| 'oauth_' parameters are added by default. This parameter too, is<br> |
| added by default but here you can override it's value.<br> |
| oauth_verifier: str (optional) If present, it is assumed that the client<br> |
| will use the OAuth v1.0a protocol which includes passing the<br> |
| oauth_verifier (as returned by the SP) in the access token step.<br> |
| <br> |
| Returns:<br> |
| Access token<br> |
| <br> |
| Raises:<br> |
| NonOAuthToken if the user's authorized request token is not an OAuth<br> |
| token or if an authorized request token was not available.<br> |
| TokenUpgradeFailed if the server responded to the request with an <br> |
| error.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-UpgradeToSessionToken"><strong>UpgradeToSessionToken</strong></a>(self, token<font color="#909090">=None</font>)</dt><dd><tt>Upgrades a single use AuthSub token to a session token.<br> |
| <br> |
| Args:<br> |
| token: A gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken<br> |
| (optional) which is good for a single use but can be upgraded<br> |
| to a session token. If no token is passed in, the token<br> |
| is found by looking in the token_store by looking for a token<br> |
| for the current scope.<br> |
| <br> |
| Raises:<br> |
| NonAuthSubToken if the user's auth token is not an AuthSub token<br> |
| TokenUpgradeFailed if the server responded to the request with an <br> |
| error.</tt></dd></dl> |
| |
| <dl><dt><a name="BookService-upgrade_to_session_token"><strong>upgrade_to_session_token</strong></a>(self, token)</dt><dd><tt>Upgrades a single use AuthSub token to a session token.<br> |
| <br> |
| Args:<br> |
| token: A gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken<br> |
| which is good for a single use but can be upgraded to a<br> |
| session token.<br> |
| <br> |
| Returns:<br> |
| The upgraded token as a gdata.auth.AuthSubToken object.<br> |
| <br> |
| Raises:<br> |
| TokenUpgradeFailed if the server responded to the request with an <br> |
| error.</tt></dd></dl> |
| |
| <hr> |
| Data descriptors inherited from <a href="gdata.service.html#GDataService">gdata.service.GDataService</a>:<br> |
| <dl><dt><strong>captcha_token</strong></dt> |
| <dd><tt>Get the captcha token for a login request.</tt></dd> |
| </dl> |
| <dl><dt><strong>captcha_url</strong></dt> |
| <dd><tt>Get the captcha URL for a login request.</tt></dd> |
| </dl> |
| <dl><dt><strong>source</strong></dt> |
| <dd><tt>The source is the name of the application making the request. <br> |
| It should be in the form company_id-app_name-app_version</tt></dd> |
| </dl> |
| <hr> |
| Data and other attributes inherited from <a href="gdata.service.html#GDataService">gdata.service.GDataService</a>:<br> |
| <dl><dt><strong>auth_token</strong> = None</dl> |
| |
| <dl><dt><strong>handler</strong> = None</dl> |
| |
| <dl><dt><strong>tokens</strong> = None</dl> |
| |
| <hr> |
| Methods inherited from <a href="atom.service.html#AtomService">atom.service.AtomService</a>:<br> |
| <dl><dt><a name="BookService-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="BookService-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="BookService-use_basic_auth"><strong>use_basic_auth</strong></a>(self, username, password, scopes<font color="#909090">=None</font>)</dt></dl> |
| |
| <hr> |
| Data descriptors inherited from <a href="atom.service.html#AtomService">atom.service.AtomService</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> |
| <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 inherited from <a href="atom.service.html#AtomService">atom.service.AtomService</a>:<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></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>ACCOUNT_TYPE</strong> = 'HOSTED_OR_GOOGLE'<br> |
| <strong>ANNOTATION_FEED</strong> = '/books/feeds/users/%s/volumes'<br> |
| <strong>BOOK_SERVER</strong> = 'books.google.com'<br> |
| <strong>BOOK_SERVICE</strong> = 'print'<br> |
| <strong>GENERAL_FEED</strong> = '/books/feeds/volumes'<br> |
| <strong>ITEM_FEED</strong> = '/books/feeds/volumes/'<br> |
| <strong>LIBRARY_FEED</strong> = '/books/feeds/users/%s/collections/library/volumes'<br> |
| <strong>PARTNER_FEED</strong> = '/books/feeds/p/%s/volumes'<br> |
| <strong>__author__</strong> = 'James Sams <sams.james@gmail.com>'<br> |
| <strong>__copyright__</strong> = 'Apache License v2.0'</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%">James Sams <sams.james@gmail.com></td></tr></table> |
| </body></html> |