| |
- exceptions.Exception(exceptions.BaseException)
-
- Error
-
- RequestError
- gdata.service.GDataService(atom.service.AtomService)
-
- SpreadsheetsService
- gdata.service.Query(__builtin__.dict)
-
- CellQuery
- DocumentQuery
- ListQuery
class CellQuery(gdata.service.Query) |
| |
- Method resolution order:
- CellQuery
- gdata.service.Query
- __builtin__.dict
- __builtin__.object
Data descriptors defined here:
- max_col
- The max-col query parameter
- max_row
- The max-row query parameter
- min_col
- The min-col query parameter
- min_row
- The min-row query parameter
- range
- The range query parameter
- return_empty
- The return-empty query parameter
Methods inherited from gdata.service.Query:
- ToUri(self)
- __init__(self, feed=None, text_query=None, params=None, categories=None)
- Constructor for Query
Args:
feed: str (optional) The path for the feed (Examples:
'/base/feeds/snippets' or 'calendar/feeds/jo@gmail.com/private/full'
text_query: str (optional) The contents of the q query parameter. The
contents of the text_query are URL escaped upon conversion to a URI.
params: dict (optional) Parameter value string pairs which become URL
params when translated to a URI. These parameters are added to the
query's items (key-value pairs).
categories: list (optional) List of category strings which should be
included as query categories. See
http://code.google.com/apis/gdata/reference.html#Queries for
details. If you want to get results from category A or B (both
categories), specify a single list item 'A|B'.
- __str__(self)
Data descriptors inherited from gdata.service.Query:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- alt
- The feed query's alt parameter
- author
- The feed query's author parameter
- max_results
- The feed query's max-results parameter
- orderby
- The feed query's orderby parameter
- published_max
- The feed query's published-max parameter
- published_min
- The feed query's published-min parameter
- start_index
- The feed query's start-index parameter
- text_query
- The feed query's q parameter
- updated_max
- The feed query's updated-max parameter
- updated_min
- The feed query's updated-min parameter
Methods inherited from __builtin__.dict:
- __cmp__(...)
- x.__cmp__(y) <==> cmp(x,y)
- __contains__(...)
- D.__contains__(k) -> True if D has a key k, else False
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __gt__(...)
- x.__gt__(y) <==> x>y
- __iter__(...)
- x.__iter__() <==> iter(x)
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __repr__(...)
- x.__repr__() <==> repr(x)
- __setitem__(...)
- x.__setitem__(i, y) <==> x[i]=y
- __sizeof__(...)
- D.__sizeof__() -> size of D in memory, in bytes
- clear(...)
- D.clear() -> None. Remove all items from D.
- copy(...)
- D.copy() -> a shallow copy of D
- fromkeys(...)
- dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.
- get(...)
- D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- has_key(...)
- D.has_key(k) -> True if D has a key k, else False
- items(...)
- D.items() -> list of D's (key, value) pairs, as 2-tuples
- iteritems(...)
- D.iteritems() -> an iterator over the (key, value) items of D
- iterkeys(...)
- D.iterkeys() -> an iterator over the keys of D
- itervalues(...)
- D.itervalues() -> an iterator over the values of D
- keys(...)
- D.keys() -> list of D's keys
- pop(...)
- D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem(...)
- D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty.
- setdefault(...)
- D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
- update(...)
- D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
- values(...)
- D.values() -> list of D's values
- viewitems(...)
- D.viewitems() -> a set-like object providing a view on D's items
- viewkeys(...)
- D.viewkeys() -> a set-like object providing a view on D's keys
- viewvalues(...)
- D.viewvalues() -> an object providing a view on D's values
Data and other attributes inherited from __builtin__.dict:
- __hash__ = None
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class DocumentQuery(gdata.service.Query) |
| |
- Method resolution order:
- DocumentQuery
- gdata.service.Query
- __builtin__.dict
- __builtin__.object
Data descriptors defined here:
- title
- The title query parameter
- title_exact
- The title-exact query parameter
Methods inherited from gdata.service.Query:
- ToUri(self)
- __init__(self, feed=None, text_query=None, params=None, categories=None)
- Constructor for Query
Args:
feed: str (optional) The path for the feed (Examples:
'/base/feeds/snippets' or 'calendar/feeds/jo@gmail.com/private/full'
text_query: str (optional) The contents of the q query parameter. The
contents of the text_query are URL escaped upon conversion to a URI.
params: dict (optional) Parameter value string pairs which become URL
params when translated to a URI. These parameters are added to the
query's items (key-value pairs).
categories: list (optional) List of category strings which should be
included as query categories. See
http://code.google.com/apis/gdata/reference.html#Queries for
details. If you want to get results from category A or B (both
categories), specify a single list item 'A|B'.
- __str__(self)
Data descriptors inherited from gdata.service.Query:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- alt
- The feed query's alt parameter
- author
- The feed query's author parameter
- max_results
- The feed query's max-results parameter
- orderby
- The feed query's orderby parameter
- published_max
- The feed query's published-max parameter
- published_min
- The feed query's published-min parameter
- start_index
- The feed query's start-index parameter
- text_query
- The feed query's q parameter
- updated_max
- The feed query's updated-max parameter
- updated_min
- The feed query's updated-min parameter
Methods inherited from __builtin__.dict:
- __cmp__(...)
- x.__cmp__(y) <==> cmp(x,y)
- __contains__(...)
- D.__contains__(k) -> True if D has a key k, else False
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __gt__(...)
- x.__gt__(y) <==> x>y
- __iter__(...)
- x.__iter__() <==> iter(x)
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __repr__(...)
- x.__repr__() <==> repr(x)
- __setitem__(...)
- x.__setitem__(i, y) <==> x[i]=y
- __sizeof__(...)
- D.__sizeof__() -> size of D in memory, in bytes
- clear(...)
- D.clear() -> None. Remove all items from D.
- copy(...)
- D.copy() -> a shallow copy of D
- fromkeys(...)
- dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.
- get(...)
- D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- has_key(...)
- D.has_key(k) -> True if D has a key k, else False
- items(...)
- D.items() -> list of D's (key, value) pairs, as 2-tuples
- iteritems(...)
- D.iteritems() -> an iterator over the (key, value) items of D
- iterkeys(...)
- D.iterkeys() -> an iterator over the keys of D
- itervalues(...)
- D.itervalues() -> an iterator over the values of D
- keys(...)
- D.keys() -> list of D's keys
- pop(...)
- D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem(...)
- D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty.
- setdefault(...)
- D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
- update(...)
- D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
- values(...)
- D.values() -> list of D's values
- viewitems(...)
- D.viewitems() -> a set-like object providing a view on D's items
- viewkeys(...)
- D.viewkeys() -> a set-like object providing a view on D's keys
- viewvalues(...)
- D.viewvalues() -> an object providing a view on D's values
Data and other attributes inherited from __builtin__.dict:
- __hash__ = None
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class ListQuery(gdata.service.Query) |
| |
- Method resolution order:
- ListQuery
- gdata.service.Query
- __builtin__.dict
- __builtin__.object
Data descriptors defined here:
- orderby
- The orderby query parameter
- reverse
- The reverse query parameter
- sq
- The sq query parameter
Methods inherited from gdata.service.Query:
- ToUri(self)
- __init__(self, feed=None, text_query=None, params=None, categories=None)
- Constructor for Query
Args:
feed: str (optional) The path for the feed (Examples:
'/base/feeds/snippets' or 'calendar/feeds/jo@gmail.com/private/full'
text_query: str (optional) The contents of the q query parameter. The
contents of the text_query are URL escaped upon conversion to a URI.
params: dict (optional) Parameter value string pairs which become URL
params when translated to a URI. These parameters are added to the
query's items (key-value pairs).
categories: list (optional) List of category strings which should be
included as query categories. See
http://code.google.com/apis/gdata/reference.html#Queries for
details. If you want to get results from category A or B (both
categories), specify a single list item 'A|B'.
- __str__(self)
Data descriptors inherited from gdata.service.Query:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- alt
- The feed query's alt parameter
- author
- The feed query's author parameter
- max_results
- The feed query's max-results parameter
- published_max
- The feed query's published-max parameter
- published_min
- The feed query's published-min parameter
- start_index
- The feed query's start-index parameter
- text_query
- The feed query's q parameter
- updated_max
- The feed query's updated-max parameter
- updated_min
- The feed query's updated-min parameter
Methods inherited from __builtin__.dict:
- __cmp__(...)
- x.__cmp__(y) <==> cmp(x,y)
- __contains__(...)
- D.__contains__(k) -> True if D has a key k, else False
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __gt__(...)
- x.__gt__(y) <==> x>y
- __iter__(...)
- x.__iter__() <==> iter(x)
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __repr__(...)
- x.__repr__() <==> repr(x)
- __setitem__(...)
- x.__setitem__(i, y) <==> x[i]=y
- __sizeof__(...)
- D.__sizeof__() -> size of D in memory, in bytes
- clear(...)
- D.clear() -> None. Remove all items from D.
- copy(...)
- D.copy() -> a shallow copy of D
- fromkeys(...)
- dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.
- get(...)
- D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- has_key(...)
- D.has_key(k) -> True if D has a key k, else False
- items(...)
- D.items() -> list of D's (key, value) pairs, as 2-tuples
- iteritems(...)
- D.iteritems() -> an iterator over the (key, value) items of D
- iterkeys(...)
- D.iterkeys() -> an iterator over the keys of D
- itervalues(...)
- D.itervalues() -> an iterator over the values of D
- keys(...)
- D.keys() -> list of D's keys
- pop(...)
- D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem(...)
- D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty.
- setdefault(...)
- D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
- update(...)
- D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
- values(...)
- D.values() -> list of D's values
- viewitems(...)
- D.viewitems() -> a set-like object providing a view on D's items
- viewkeys(...)
- D.viewkeys() -> a set-like object providing a view on D's keys
- viewvalues(...)
- D.viewvalues() -> an object providing a view on D's values
Data and other attributes inherited from __builtin__.dict:
- __hash__ = None
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class SpreadsheetsService(gdata.service.GDataService) |
|
Client for the Google Spreadsheets service. |
|
- Method resolution order:
- SpreadsheetsService
- gdata.service.GDataService
- atom.service.AtomService
- __builtin__.object
Methods defined here:
- AddWorksheet(self, title, row_count, col_count, key)
- Creates a new worksheet in the desired spreadsheet.
The new worksheet is appended to the end of the list of worksheets. The
new worksheet will only have the available number of columns and cells
specified.
Args:
title: str The title which will be displayed in the list of worksheets.
row_count: int or str The number of rows in the new worksheet.
col_count: int or str The number of columns in the new worksheet.
key: str The spreadsheet key to the spreadsheet to which the new
worksheet should be added.
Returns:
A SpreadsheetsWorksheet if the new worksheet was created succesfully.
- DeleteRow(self, entry)
- Deletes a row, the provided entry
Args:
entry: gdata.spreadsheet.SpreadsheetsList The row to be deleted
Returns:
The delete response
- DeleteWorksheet(self, worksheet_entry=None, url=None)
- Removes the desired worksheet from the spreadsheet
Args:
worksheet_entry: SpreadsheetWorksheet (optional) The worksheet to
be deleted. If this is none, then the DELETE reqest is sent to
the url specified in the url parameter.
url: str (optaional) The URL to which the DELETE request should be
sent. If left as None, the worksheet's edit URL is used.
Returns:
True if the worksheet was deleted successfully.
- ExecuteBatch(self, batch_feed, url=None, spreadsheet_key=None, worksheet_id=None, converter=<function SpreadsheetsCellsFeedFromString>)
- Sends a batch request feed to the server.
The batch request needs to be sent to the batch URL for a particular
worksheet. You can specify the worksheet by providing the spreadsheet_key
and worksheet_id, or by sending the URL from the cells feed's batch link.
Args:
batch_feed: gdata.spreadsheet.SpreadsheetsCellFeed A feed containing
BatchEntry elements which contain the desired CRUD operation and
any necessary data to modify a cell.
url: str (optional) The batch URL for the cells feed to which these
changes should be applied. This can be found by calling
cells_feed.GetBatchLink().href.
spreadsheet_key: str (optional) Used to generate the batch request URL
if the url argument is None. If using the spreadsheet key to
generate the URL, the worksheet id is also required.
worksheet_id: str (optional) Used if the url is not provided, it is
oart of the batch feed target URL. This is used with the spreadsheet
key.
converter: Function (optional) Function to be executed on the server's
response. This function should take one string as a parameter. The
default value is SpreadsheetsCellsFeedFromString which will turn the result
into a gdata.spreadsheet.SpreadsheetsCellsFeed object.
Returns:
A gdata.BatchFeed containing the results.
- GetCellsFeed(self, key, wksht_id='default', cell=None, query=None, visibility='private', projection='full')
- Gets a cells feed or a specific entry if a cell is defined
Args:
key: string The spreadsheet key defined in /ccc?key=
wksht_id: string The id for a specific worksheet entry
cell: string (optional) The R1C1 address of the cell
query: DocumentQuery (optional) Query parameters
Returns:
If there is no cell, then a SpreadsheetsCellsFeed.
If there is a cell, then a SpreadsheetsCell.
- GetListFeed(self, key, wksht_id='default', row_id=None, query=None, visibility='private', projection='full')
- Gets a list feed or a specific entry if a row_id is defined
Args:
key: string The spreadsheet key defined in /ccc?key=
wksht_id: string The id for a specific worksheet entry
row_id: string (optional) The row_id of a row in the list
query: DocumentQuery (optional) Query parameters
Returns:
If there is no row_id, then a SpreadsheetsListFeed.
If there is a row_id, then a SpreadsheetsList.
- GetSpreadsheetsFeed(self, key=None, query=None, visibility='private', projection='full')
- Gets a spreadsheets feed or a specific entry if a key is defined
Args:
key: string (optional) The spreadsheet key defined in /ccc?key=
query: DocumentQuery (optional) Query parameters
Returns:
If there is no key, then a SpreadsheetsSpreadsheetsFeed.
If there is a key, then a SpreadsheetsSpreadsheet.
- GetWorksheetsFeed(self, key, wksht_id=None, query=None, visibility='private', projection='full')
- Gets a worksheets feed or a specific entry if a wksht is defined
Args:
key: string The spreadsheet key defined in /ccc?key=
wksht_id: string (optional) The id for a specific worksheet entry
query: DocumentQuery (optional) Query parameters
Returns:
If there is no wksht_id, then a SpreadsheetsWorksheetsFeed.
If there is a wksht_id, then a SpreadsheetsWorksheet.
- InsertRow(self, row_data, key, wksht_id='default')
- Inserts a new row with the provided data
Args:
uri: string The post uri of the list feed
row_data: dict A dictionary of column header to row data
Returns:
The inserted row
- UpdateCell(self, row, col, inputValue, key, wksht_id='default')
- Updates an existing cell.
Args:
row: int The row the cell to be editted is in
col: int The column the cell to be editted is in
inputValue: str the new value of the cell
key: str The key of the spreadsheet in which this cell resides.
wksht_id: str The ID of the worksheet which holds this cell.
Returns:
The updated cell entry
- UpdateRow(self, entry, new_row_data)
- Updates a row with the provided data
If you want to add additional information to a row, it is often
easier to change the values in entry.custom, then use the Put
method instead of UpdateRow. This UpdateRow method will replace
the contents of the row with new_row_data - it will change all columns
not just the columns specified in the new_row_data dict.
Args:
entry: gdata.spreadsheet.SpreadsheetsList The entry to be updated
new_row_data: dict A dictionary of column header to row data
Returns:
The updated row
- UpdateWorksheet(self, worksheet_entry, url=None)
- Changes the size and/or title of the desired worksheet.
Args:
worksheet_entry: SpreadsheetWorksheet The new contents of the
worksheet.
url: str (optional) The URL to which the edited worksheet entry should
be sent. If the url is None, the edit URL from the worksheet will
be used.
Returns:
A SpreadsheetsWorksheet with the new information about the worksheet.
- __init__(self, email=None, password=None, source=None, server='spreadsheets.google.com', additional_headers=None, **kwargs)
- Creates a client for the Google Spreadsheets service.
Args:
email: string (optional) The user's email address, used for
authentication.
password: string (optional) The user's password.
source: string (optional) The name of the user's application.
server: string (optional) The name of the server to which a connection
will be opened. Default value: 'spreadsheets.google.com'.
**kwargs: The other parameters to pass to gdata.service.GDataService
constructor.
Methods inherited from gdata.service.GDataService:
- AuthSubTokenInfo(self)
- Fetches the AuthSub token's metadata from the server.
Raises:
NonAuthSubToken if the user's auth token is not an AuthSub token
- ClientLogin(self, username, password, account_type=None, service=None, auth_service_url=None, source=None, captcha_token=None, captcha_response=None)
- Convenience method for authenticating using ProgrammaticLogin.
Sets values for email, password, and other optional members.
Args:
username:
password:
account_type: string (optional)
service: string (optional)
auth_service_url: string (optional)
captcha_token: string (optional)
captcha_response: string (optional)
- Delete(self, uri, extra_headers=None, url_params=None, escape_params=True, redirects_remaining=4)
- Deletes the entry at the given URI.
Args:
uri: string The URI of the entry to be deleted. Example:
'/base/feeds/items/ITEM-ID'
extra_headers: dict (optional) HTTP headers which are to be included.
The client automatically sets the Content-Type and
Authorization headers.
url_params: dict (optional) Additional URL parameters to be included
in the URI. These are translated into query arguments
in the form '&dict_key=value&...'.
Example: {'max-results': '250'} becomes &max-results=250
escape_params: boolean (optional) If false, the calling code has already
ensured that the query will form a valid URL (all
reserved characters have been escaped). If true, this
method will escape the query and any URL parameters
provided.
Returns:
True if the entry was deleted.
- FetchOAuthRequestToken(self, scopes=None, extra_parameters=None, request_url='https://www.google.com/accounts/OAuthGetRequestToken', oauth_callback=None)
- Fetches and sets the OAuth request token and returns it.
Args:
scopes: string or list of string base URL(s) of the service(s) to be
accessed. If None, then this method tries to determine the
scope(s) from the current service.
extra_parameters: dict (optional) key-value pairs as any additional
parameters to be included in the URL and signature while making a
request for fetching an OAuth request token. All the OAuth parameters
are added by default. But if provided through this argument, any
default parameters will be overwritten. For e.g. a default parameter
oauth_version 1.0 can be overwritten if
extra_parameters = {'oauth_version': '2.0'}
request_url: Request token URL. The default is
'https://www.google.com/accounts/OAuthGetRequestToken'.
oauth_callback: str (optional) If set, it is assume the client is using
the OAuth v1.0a protocol where the callback url is sent in the
request token step. If the oauth_callback is also set in
extra_params, this value will override that one.
Returns:
The fetched request token as a gdata.auth.OAuthToken object.
Raises:
FetchingOAuthRequestTokenFailed if the server responded to the request
with an error.
- GenerateAuthSubURL(self, next, scope, secure=False, session=True, domain='default')
- Generate a URL at which the user will login and be redirected back.
Users enter their credentials on a Google login page and a token is sent
to the URL specified in next. See documentation for AuthSub login at:
http://code.google.com/apis/accounts/docs/AuthSub.html
Args:
next: string The URL user will be sent to after logging in.
scope: string or list of strings. The URLs of the services to be
accessed.
secure: boolean (optional) Determines whether or not the issued token
is a secure token.
session: boolean (optional) Determines whether or not the issued token
can be upgraded to a session token.
- GenerateOAuthAuthorizationURL(self, request_token=None, callback_url=None, extra_params=None, include_scopes_in_callback=False, scopes_param_prefix='oauth_token_scope', request_url='https://www.google.com/accounts/OAuthAuthorizeToken')
- Generates URL at which user will login to authorize the request token.
Args:
request_token: gdata.auth.OAuthToken (optional) OAuth request token.
If not specified, then the current token will be used if it is of
type <gdata.auth.OAuthToken>, else it is found by looking in the
token_store by looking for a token for the current scope.
callback_url: string (optional) The URL user will be sent to after
logging in and granting access.
extra_params: dict (optional) Additional parameters to be sent.
include_scopes_in_callback: Boolean (default=False) if set to True, and
if 'callback_url' is present, the 'callback_url' will be modified to
include the scope(s) from the request token as a URL parameter. The
key for the 'callback' URL's scope parameter will be
OAUTH_SCOPE_URL_PARAM_NAME. The benefit of including the scope URL as
a parameter to the 'callback' URL, is that the page which receives
the OAuth token will be able to tell which URLs the token grants
access to.
scopes_param_prefix: string (default='oauth_token_scope') The URL
parameter key which maps to the list of valid scopes for the token.
This URL parameter will be included in the callback URL along with
the scopes of the token as value if include_scopes_in_callback=True.
request_url: Authorization URL. The default is
'https://www.google.com/accounts/OAuthAuthorizeToken'.
Returns:
A string URL at which the user is required to login.
Raises:
NonOAuthToken if the user's request token is not an OAuth token or if a
request token was not available.
- Get(self, uri, extra_headers=None, redirects_remaining=4, encoding='UTF-8', converter=None)
- Query the GData API with the given URI
The uri is the portion of the URI after the server value
(ex: www.google.com).
To perform a query against Google Base, set the server to
'base.google.com' and set the uri to '/base/feeds/...', where ... is
your query. For example, to find snippets for all digital cameras uri
should be set to: '/base/feeds/snippets?bq=digital+camera'
Args:
uri: string The query in the form of a URI. Example:
'/base/feeds/snippets?bq=digital+camera'.
extra_headers: dictionary (optional) Extra HTTP headers to be included
in the GET request. These headers are in addition to
those stored in the client's additional_headers property.
The client automatically sets the Content-Type and
Authorization headers.
redirects_remaining: int (optional) Tracks the number of additional
redirects this method will allow. If the service object receives
a redirect and remaining is 0, it will not follow the redirect.
This was added to avoid infinite redirect loops.
encoding: string (optional) The character encoding for the server's
response. Default is UTF-8
converter: func (optional) A function which will transform
the server's results before it is returned. Example: use
GDataFeedFromString to parse the server response as if it
were a GDataFeed.
Returns:
If there is no ResultsTransformer specified in the call, a GDataFeed
or GDataEntry depending on which is sent from the server. If the
response is niether a feed or entry and there is no ResultsTransformer,
return a string. If there is a ResultsTransformer, the returned value
will be that of the ResultsTransformer function.
- GetAuthSubToken(self)
- Returns the AuthSub token as a string.
If the token is an gdta.auth.AuthSubToken, the Authorization Label
("AuthSub token") is removed.
This method examines the current_token to see if it is an AuthSubToken
or SecureAuthSubToken. If not, it searches the token_store for a token
which matches the current scope.
The current scope is determined by the service name string member.
Returns:
If the current_token is set to an AuthSubToken/SecureAuthSubToken,
return the token string. If there is no current_token, a token string
for a token which matches the service object's default scope is returned.
If there are no tokens valid for the scope, returns None.
- GetClientLoginToken(self)
- Returns the token string for the current token or a token matching the
service scope.
If the current_token is a ClientLoginToken, the token string for
the current token is returned. If the current_token is not set, this method
searches for a token in the token_store which is valid for the service
object's current scope.
The current scope is determined by the service name string member.
The token string is the end of the Authorization header, it doesn not
include the ClientLogin label.
- GetEntry(self, uri, extra_headers=None)
- Query the GData API with the given URI and receive an Entry.
See also documentation for gdata.service.Get
Args:
uri: string The query in the form of a URI. Example:
'/base/feeds/snippets?bq=digital+camera'.
extra_headers: dictionary (optional) Extra HTTP headers to be included
in the GET request. These headers are in addition to
those stored in the client's additional_headers property.
The client automatically sets the Content-Type and
Authorization headers.
Returns:
A GDataEntry built from the XML in the server's response.
- GetFeed(self, uri, extra_headers=None, converter=<function GDataFeedFromString>)
- Query the GData API with the given URI and receive a Feed.
See also documentation for gdata.service.Get
Args:
uri: string The query in the form of a URI. Example:
'/base/feeds/snippets?bq=digital+camera'.
extra_headers: dictionary (optional) Extra HTTP headers to be included
in the GET request. These headers are in addition to
those stored in the client's additional_headers property.
The client automatically sets the Content-Type and
Authorization headers.
Returns:
A GDataFeed built from the XML in the server's response.
- GetGeneratorFromLinkFinder(self, link_finder, func, num_retries=3, delay=1, backoff=2)
- returns a generator for pagination
- GetMedia(self, uri, extra_headers=None)
- Returns a MediaSource containing media and its metadata from the given
URI string.
- GetNext(self, feed)
- Requests the next 'page' of results in the feed.
This method uses the feed's next link to request an additional feed
and uses the class of the feed to convert the results of the GET request.
Args:
feed: atom.Feed or a subclass. The feed should contain a next link and
the type of the feed will be applied to the results from the
server. The new feed which is returned will be of the same class
as this feed which was passed in.
Returns:
A new feed representing the next set of results in the server's feed.
The type of this feed will match that of the feed argument.
- GetOAuthInputParameters(self)
- GetWithRetries(self, uri, extra_headers=None, redirects_remaining=4, encoding='UTF-8', converter=None, num_retries=3, delay=1, backoff=2, logger=None)
- This is a wrapper method for Get with retrying capability.
To avoid various errors while retrieving bulk entities by retrying
specified times.
Note this method relies on the time module and so may not be usable
by default in Python2.2.
Args:
num_retries: Integer; the retry count.
delay: Integer; the initial delay for retrying.
backoff: Integer; how much the delay should lengthen after each failure.
logger: An object which has a debug(str) method to receive logging
messages. Recommended that you pass in the logging module.
Raises:
ValueError if any of the parameters has an invalid value.
RanOutOfTries on failure after number of retries.
- Post(self, data, uri, extra_headers=None, url_params=None, escape_params=True, redirects_remaining=4, media_source=None, converter=None)
- Insert or update data into a GData service at the given URI.
Args:
data: string, ElementTree._Element, atom.Entry, or gdata.GDataEntry The
XML to be sent to the uri.
uri: string The location (feed) to which the data should be inserted.
Example: '/base/feeds/items'.
extra_headers: dict (optional) HTTP headers which are to be included.
The client automatically sets the Content-Type,
Authorization, and Content-Length headers.
url_params: dict (optional) Additional URL parameters to be included
in the URI. These are translated into query arguments
in the form '&dict_key=value&...'.
Example: {'max-results': '250'} becomes &max-results=250
escape_params: boolean (optional) If false, the calling code has already
ensured that the query will form a valid URL (all
reserved characters have been escaped). If true, this
method will escape the query and any URL parameters
provided.
media_source: MediaSource (optional) Container for the media to be sent
along with the entry, if provided.
converter: func (optional) A function which will be executed on the
server's response. Often this is a function like
GDataEntryFromString which will parse the body of the server's
response and return a GDataEntry.
Returns:
If the post succeeded, this method will return a GDataFeed, GDataEntry,
or the results of running converter on the server's result body (if
converter was specified).
- PostOrPut(self, verb, data, uri, extra_headers=None, url_params=None, escape_params=True, redirects_remaining=4, media_source=None, converter=None)
- Insert data into a GData service at the given URI.
Args:
verb: string, either 'POST' or 'PUT'
data: string, ElementTree._Element, atom.Entry, or gdata.GDataEntry The
XML to be sent to the uri.
uri: string The location (feed) to which the data should be inserted.
Example: '/base/feeds/items'.
extra_headers: dict (optional) HTTP headers which are to be included.
The client automatically sets the Content-Type,
Authorization, and Content-Length headers.
url_params: dict (optional) Additional URL parameters to be included
in the URI. These are translated into query arguments
in the form '&dict_key=value&...'.
Example: {'max-results': '250'} becomes &max-results=250
escape_params: boolean (optional) If false, the calling code has already
ensured that the query will form a valid URL (all
reserved characters have been escaped). If true, this
method will escape the query and any URL parameters
provided.
media_source: MediaSource (optional) Container for the media to be sent
along with the entry, if provided.
converter: func (optional) A function which will be executed on the
server's response. Often this is a function like
GDataEntryFromString which will parse the body of the server's
response and return a GDataEntry.
Returns:
If the post succeeded, this method will return a GDataFeed, GDataEntry,
or the results of running converter on the server's result body (if
converter was specified).
- ProgrammaticLogin(self, captcha_token=None, captcha_response=None)
- Authenticates the user and sets the GData Auth token.
Login retreives a temporary auth token which must be used with all
requests to GData services. The auth token is stored in the GData client
object.
Login is also used to respond to a captcha challenge. If the user's login
attempt failed with a CaptchaRequired error, the user can respond by
calling Login with the captcha token and the answer to the challenge.
Args:
captcha_token: string (optional) The identifier for the captcha challenge
which was presented to the user.
captcha_response: string (optional) The user's answer to the captch
challenge.
Raises:
CaptchaRequired if the login service will require a captcha response
BadAuthentication if the login service rejected the username or password
Error if the login service responded with a 403 different from the above
- Put(self, data, uri, extra_headers=None, url_params=None, escape_params=True, redirects_remaining=3, media_source=None, converter=None)
- Updates an entry at the given URI.
Args:
data: string, ElementTree._Element, or xml_wrapper.ElementWrapper The
XML containing the updated data.
uri: string A URI indicating entry to which the update will be applied.
Example: '/base/feeds/items/ITEM-ID'
extra_headers: dict (optional) HTTP headers which are to be included.
The client automatically sets the Content-Type,
Authorization, and Content-Length headers.
url_params: dict (optional) Additional URL parameters to be included
in the URI. These are translated into query arguments
in the form '&dict_key=value&...'.
Example: {'max-results': '250'} becomes &max-results=250
escape_params: boolean (optional) If false, the calling code has already
ensured that the query will form a valid URL (all
reserved characters have been escaped). If true, this
method will escape the query and any URL parameters
provided.
converter: func (optional) A function which will be executed on the
server's response. Often this is a function like
GDataEntryFromString which will parse the body of the server's
response and return a GDataEntry.
Returns:
If the put succeeded, this method will return a GDataFeed, GDataEntry,
or the results of running converter on the server's result body (if
converter was specified).
- RevokeAuthSubToken(self)
- Revokes an existing AuthSub token.
Raises:
NonAuthSubToken if the user's auth token is not an AuthSub token
- RevokeOAuthToken(self, request_url='https://www.google.com/accounts/AuthSubRevokeToken')
- Revokes an existing OAuth token.
request_url: Token revoke URL. The default is
'https://www.google.com/accounts/AuthSubRevokeToken'.
Raises:
NonOAuthToken if the user's auth token is not an OAuth token.
RevokingOAuthTokenFailed if request for revoking an OAuth token failed.
- SetAuthSubToken(self, token, scopes=None, rsa_key=None)
- Sets the token sent in requests to an AuthSub token.
Sets the current_token and attempts to add the token to the token_store.
Only use this method if you have received a token from the AuthSub
service. The auth token is set automatically when UpgradeToSessionToken()
is used. See documentation for Google AuthSub here:
http://code.google.com/apis/accounts/AuthForWebApps.html
Args:
token: gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken or string
The token returned by the AuthSub service. If the token is an
AuthSubToken or SecureAuthSubToken, the scope information stored in
the token is used. If the token is a string, the scopes parameter is
used to determine the valid scopes.
scopes: list of URLs for which the token is valid. This is only used
if the token parameter is a string.
rsa_key: string (optional) Private key required for RSA_SHA1 signature
method. This parameter is necessary if the token is a string
representing a secure token.
- SetClientLoginToken(self, token, scopes=None)
- Sets the token sent in requests to a ClientLogin token.
This method sets the current_token to a new ClientLoginToken and it
also attempts to add the ClientLoginToken to the token_store.
Only use this method if you have received a token from the ClientLogin
service. The auth_token is set automatically when ProgrammaticLogin()
is used. See documentation for Google ClientLogin here:
http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html
Args:
token: string or instance of a ClientLoginToken.
- SetOAuthInputParameters(self, signature_method, consumer_key, consumer_secret=None, rsa_key=None, two_legged_oauth=False, requestor_id=None)
- Sets parameters required for using OAuth authentication mechanism.
NOTE: Though consumer_secret and rsa_key are optional, either of the two
is required depending on the value of the signature_method.
Args:
signature_method: class which provides implementation for strategy class
oauth.oauth.OAuthSignatureMethod. Signature method to be used for
signing each request. Valid implementations are provided as the
constants defined by gdata.auth.OAuthSignatureMethod. Currently
they are gdata.auth.OAuthSignatureMethod.RSA_SHA1 and
gdata.auth.OAuthSignatureMethod.HMAC_SHA1
consumer_key: string Domain identifying third_party web application.
consumer_secret: string (optional) Secret generated during registration.
Required only for HMAC_SHA1 signature method.
rsa_key: string (optional) Private key required for RSA_SHA1 signature
method.
two_legged_oauth: boolean (optional) Enables two-legged OAuth process.
requestor_id: string (optional) User email adress to make requests on
their behalf. This parameter should only be set when two_legged_oauth
is True.
- SetOAuthToken(self, oauth_token)
- Attempts to set the current token and add it to the token store.
The oauth_token can be any OAuth token i.e. unauthorized request token,
authorized request token or access token.
This method also attempts to add the token to the token store.
Use this method any time you want the current token to point to the
oauth_token passed. For e.g. call this method with the request token
you receive from FetchOAuthRequestToken.
Args:
request_token: gdata.auth.OAuthToken OAuth request token.
- UpgradeToOAuthAccessToken(self, authorized_request_token=None, request_url='https://www.google.com/accounts/OAuthGetAccessToken', oauth_version='1.0', oauth_verifier=None)
- Upgrades the authorized request token to an access token and returns it
Args:
authorized_request_token: gdata.auth.OAuthToken (optional) OAuth request
token. If not specified, then the current token will be used if it is
of type <gdata.auth.OAuthToken>, else it is found by looking in the
token_store by looking for a token for the current scope.
request_url: Access token URL. The default is
'https://www.google.com/accounts/OAuthGetAccessToken'.
oauth_version: str (default='1.0') oauth_version parameter. All other
'oauth_' parameters are added by default. This parameter too, is
added by default but here you can override it's value.
oauth_verifier: str (optional) If present, it is assumed that the client
will use the OAuth v1.0a protocol which includes passing the
oauth_verifier (as returned by the SP) in the access token step.
Returns:
Access token
Raises:
NonOAuthToken if the user's authorized request token is not an OAuth
token or if an authorized request token was not available.
TokenUpgradeFailed if the server responded to the request with an
error.
- UpgradeToSessionToken(self, token=None)
- Upgrades a single use AuthSub token to a session token.
Args:
token: A gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken
(optional) which is good for a single use but can be upgraded
to a session token. If no token is passed in, the token
is found by looking in the token_store by looking for a token
for the current scope.
Raises:
NonAuthSubToken if the user's auth token is not an AuthSub token
TokenUpgradeFailed if the server responded to the request with an
error.
- upgrade_to_session_token(self, token)
- Upgrades a single use AuthSub token to a session token.
Args:
token: A gdata.auth.AuthSubToken or gdata.auth.SecureAuthSubToken
which is good for a single use but can be upgraded to a
session token.
Returns:
The upgraded token as a gdata.auth.AuthSubToken object.
Raises:
TokenUpgradeFailed if the server responded to the request with an
error.
Data descriptors inherited from gdata.service.GDataService:
- captcha_token
- Get the captcha token for a login request.
- captcha_url
- Get the captcha URL for a login request.
- source
- The source is the name of the application making the request.
It should be in the form company_id-app_name-app_version
Data and other attributes inherited from gdata.service.GDataService:
- auth_token = None
- handler = None
- tokens = None
Methods inherited from atom.service.AtomService:
- UseBasicAuth(self, username, password, for_proxy=False)
- Sets an Authenticaiton: Basic HTTP header containing plaintext.
Deprecated, use use_basic_auth instead.
The username and password are base64 encoded and added to an HTTP header
which will be included in each request. Note that your username and
password are sent in plaintext.
Args:
username: str
password: str
- request(*args, **kwargs)
- # The deprecated_function wraps the actual call to f.
- use_basic_auth(self, username, password, scopes=None)
Data descriptors inherited from atom.service.AtomService:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- debug
- If True, HTTP debug information is printed.
- override_token
Data and other attributes inherited from atom.service.AtomService:
- auto_set_current_token = True
- auto_store_tokens = True
- current_token = None
- port = 80
- ssl = False
| |