gdata.service
index
/usr/local/svn/gdata-python-client/src/gdata/service.py

GDataService provides CRUD ops. and programmatic login for GData services.
 
Error: A base exception class for all exceptions in the gdata_client
       module.
 
CaptchaRequired: This exception is thrown when a login attempt results in a
                 captcha challenge from the ClientLogin service. When this
                 exception is thrown, the captcha_token and captcha_url are
                 set to the values provided in the server's response.
 
BadAuthentication: Raised when a login attempt is made with an incorrect
                   username or password.
 
NotAuthenticated: Raised if an operation requiring authentication is called
                  before a user has authenticated.
 
NonAuthSubToken: Raised if a method to modify an AuthSub token is used when
                 the user is either not authenticated or is authenticated
                 through programmatic login.
 
RequestError: Raised if a CRUD request returned a non-success code. 
 
UnexpectedReturnType: Raised if the response from the server was not of the
                      desired type. For example, this would be raised if the
                      server sent a feed when the client requested an entry.
 
GDataService: Encapsulates user credentials needed to perform insert, update
              and delete operations with the GData API. An instance can
              perform user authentication, query, insertion, deletion, and 
              update.
 
Query: Eases query URI creation by allowing URI parameters to be set as 
       dictionary attributes. For example a query with a feed of 
       '/base/feeds/snippets' and ['bq'] set to 'digital camera' will 
       produce '/base/feeds/snippets?bq=digital+camera' when .ToUri() is 
       called on it.

 
Modules
       
xml.etree.cElementTree
atom
gdata
atom.service
re
urllib
urlparse

 
Classes
       
__builtin__.dict(__builtin__.object)
Query
atom.service.AtomService(__builtin__.object)
GDataService
exceptions.Exception(exceptions.BaseException)
Error
AuthorizationRequired
BadAuthentication
BadAuthenticationServiceURL
CaptchaRequired
NonAuthSubToken
NotAuthenticated
RequestError
TokenHadNoScope
TokenUpgradeFailed
UnexpectedReturnType

 
class AuthorizationRequired(Error)
    
Method resolution order:
AuthorizationRequired
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class BadAuthentication(Error)
    
Method resolution order:
BadAuthentication
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class BadAuthenticationServiceURL(Error)
    
Method resolution order:
BadAuthenticationServiceURL
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class CaptchaRequired(Error)
    
Method resolution order:
CaptchaRequired
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class Error(exceptions.Exception)
    
Method resolution order:
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class GDataService(atom.service.AtomService)
    Contains elements needed for GData login and CRUD request headers.
 
Maintains additional headers (tokens for example) needed for the GData 
services to allow a user to perform inserts, updates, and deletes.
 
 
Method resolution order:
GDataService
atom.service.AtomService
__builtin__.object

Methods defined here:
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.
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/AuthForWebApps.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.
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 string (after removing the AuthSub 
Authorization Label).    
 
The AuthSub Authorization Label reads: "AuthSub token"
 
This method examines the current_token to see if it is an AuthSubToken.
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, 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 at 0x8f1140>)
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.
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.
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
SetAuthSubToken(self, token, scopes=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 string The token returned by the
        AuthSub service. If the token is an AuthSubToken, the scope
        information stored in the AuthSubToken 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.
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.
UpgradeToSessionToken(self, token=None)
Upgrades a single use AuthSub token to a session token.
 
Args:
  token: A gdata.auth.AuthSubToken (optional) which is good for a single
         use but can be upgraded to a session token. If no token is 
         passed in, the AuthSubToken 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.
__init__(self, email=None, password=None, account_type='HOSTED_OR_GOOGLE', service=None, auth_service_url=None, source=None, server=None, additional_headers=None, handler=None, tokens=None, http_client=None, token_store=None)
Creates an object of type GDataService.
 
Args:
  email: string (optional) The user's email address, used for
      authentication.
  password: string (optional) The user's password.
  account_type: string (optional) The type of account to use. Use
      'GOOGLE' for regular Google accounts or 'HOSTED' for Google
      Apps accounts, or 'HOSTED_OR_GOOGLE' to try finding a HOSTED
      account first and, if it doesn't exist, try finding a regular
      GOOGLE account. Default value: 'HOSTED_OR_GOOGLE'.
  service: string (optional) The desired service for which credentials
      will be obtained.
  auth_service_url: string (optional) User-defined auth token request URL
      allows users to explicitly specify where to send auth token requests.
  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: 'base.google.com'.
  additional_headers: dictionary (optional) Any additional headers which 
      should be included with CRUD operations.
  handler: module (optional) This parameter is deprecated and has been
      replaced by http_client.
  tokens: This parameter is deprecated, calls should be made to 
      token_store instead.
  http_client: An object responsible for making HTTP requests using a
      request method. If none is provided, a new instance of
      atom.http.ProxiedHttpClient will be used.
  token_store: Keeps a collection of authorization tokens which can be
      applied to requests for a specific URLs. Critical methods are
      find_token based on a URL (atom.url.Url or a string), add_token,
      and remove_token.
upgrade_to_session_token(self, token)
Upgrades a single use AuthSub token to a session token.
 
Args:
  token: A gdata.auth.AuthSubToken (optional) 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 defined here:
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 defined here:
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(self, operation, url, data=None, headers=None, url_params=None)
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

 
class NonAuthSubToken(Error)
    
Method resolution order:
NonAuthSubToken
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class NotAuthenticated(Error)
    
Method resolution order:
NotAuthenticated
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class Query(__builtin__.dict)
    Constructs a query URL to be used in GET requests
 
Url parameters are created by adding key-value pairs to this object as a 
dict. For example, to add &max-results=25 to the URL do
my_query['max-results'] = 25
 
Category queries are created by adding category strings to the categories
member. All items in the categories list will be concatenated with the /
symbol (symbolizing a category x AND y restriction). If you would like to OR
2 categories, append them as one string with a | between the categories. 
For example, do query.categories.append('Fritz|Laurie') to create a query
like this feed/-/Fritz%7CLaurie . This query will look for results in both
categories.
 
 
Method resolution order:
Query
__builtin__.dict
__builtin__.object

Methods defined here:
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 defined here:
__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
__hash__(...)
x.__hash__() <==> hash(x)
__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
clear(...)
D.clear() -> None.  Remove all items from D.
copy(...)
D.copy() -> a shallow copy of D
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 E and F: for k in E: D[k] = E[k]
(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]
values(...)
D.values() -> list of D's values

Data and other attributes inherited from __builtin__.dict:
__new__ = <built-in method __new__ of type object at 0x72b260>
T.__new__(S, ...) -> a new object with type S, a subtype of T
fromkeys = <built-in method fromkeys of type object at 0x7fbea0>
dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.

 
class RequestError(Error)
    
Method resolution order:
RequestError
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class TokenHadNoScope(Error)
    
Method resolution order:
TokenHadNoScope
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class TokenUpgradeFailed(Error)
    
Method resolution order:
TokenUpgradeFailed
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class UnexpectedReturnType(Error)
    
Method resolution order:
UnexpectedReturnType
Error
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors inherited from Error:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x722d20>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
Functions
       
ExtractToken(url, scopes_included_in_next=True)
Gets the AuthSub token from the current page's URL.
 
Designed to be used on the URL that the browser is sent to after the user
authorizes this application at the page given by GenerateAuthSubRequestUrl.
 
Args:
  url: The current page's URL. It should contain the token as a URL
      parameter. Example: 'http://example.com/?...&token=abcd435'
  scopes_included_in_next: If True, this function looks for a scope value
      associated with the token. The scope is a URL parameter with the
      key set to SCOPE_URL_PARAM_NAME. This parameter should be present
      if the AuthSub request URL was generated using
      GenerateAuthSubRequestUrl with include_scope_in_next set to True.
 
Returns:
  A tuple containing the token string and a list of scope strings for which
  this token should be valid. If the scope was not included in the URL, the
  tuple will contain (token, None).
GenerateAuthSubRequestUrl(next, scopes, hd='default', secure=False, session=True, request_url='http://www.google.com/accounts/AuthSubRequest', include_scopes_in_next=True)
Creates a URL to request an AuthSub token to access Google services.
 
For more details on AuthSub, see the documentation here:
http://code.google.com/apis/accounts/docs/AuthSub.html
 
Args:
  next: The URL where the browser should be sent after the user authorizes
      the application. This page is responsible for receiving the token
      which is embeded in the URL as a parameter.
  scopes: The base URL to which access will be granted. Example:
      'http://www.google.com/calendar/feeds' will grant access to all
      URLs in the Google Calendar data API. If you would like a token for
      multiple scopes, pass in a list of URL strings.
  hd: The domain to which the user's account belongs. This is set to the
      domain name if you are using Google Apps. Example: 'example.org'
      Defaults to 'default'
  secure: If set to True, all requests should be signed. The default is
      False.
  session: If set to True, the token received by the 'next' URL can be
      upgraded to a multiuse session token. If session is set to False, the
      token may only be used once and cannot be upgraded. Default is True.
  request_url: The base of the URL to which the user will be sent to
      authorize this application to access their data. The default is
      'http://www.google.com/accounts/AuthSubRequest'.
  include_scopes_in_next: Boolean if set to true, the 'next' parameter will
      be modified to include the requested scope as a URL parameter. The
      key for the next's scope parameter will be SCOPE_URL_PARAM_NAME. The
      benefit of including the scope URL as a parameter to the next URL, is
      that the page which receives the AuthSub token will be able to tell
      which URLs the token grants access to.
 
Returns:
  A URL string to which the browser should be sent.
lookup_scopes(service_name)
Finds the scope URLs for the desired service.
 
In some cases, an unknown service may be used, and in those cases this
function will return None.

 
Data
        AUTH_SERVER_HOST = 'https://www.google.com'
CLIENT_LOGIN_SCOPES = {'apps': ['http://www.google.com/a/feeds/', 'https://www.google.com/a/feeds/', 'http://apps-apis.google.com/a/feeds/', 'https://apps-apis.google.com/a/feeds/'], 'blogger': ['http://www.blogger.com/feeds/'], 'cl': ['https://www.google.com/calendar/feeds/', 'http://www.google.com/calendar/feeds/'], 'codesearch': ['http://www.google.com/codesearch/feeds/'], 'cp': ['https://www.google.com/m8/feeds/', 'http://www.google.com/m8/feeds/'], 'finance': ['http://finance.google.com/finance/feeds/'], 'gbase': ['http://base.google.com/base/feeds/', 'http://www.google.com/base/feeds/'], 'health': ['https://www.google.com/health/feeds/'], 'lh2': ['http://picasaweb.google.com/data/'], 'sitemaps': ['https://www.google.com/webmasters/tools/feeds/'], ...}
SCOPE_URL_PARAM_NAME = 'authsub_token_scope'
__author__ = 'api.jscudder (Jeffrey Scudder)'

 
Author
        api.jscudder (Jeffrey Scudder)