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

SitesClient extends gdata.client.GDClient to streamline Sites API calls.

 
Modules
       
atom
gdata

 
Classes
       
gdata.client.GDClient(atom.client.AtomPubClient)
SitesClient

 
class SitesClient(gdata.client.GDClient)
    Client extension for the Google Sites API service.
 
 
Method resolution order:
SitesClient
gdata.client.GDClient
atom.client.AtomPubClient
__builtin__.object

Methods defined here:
CreatePage = create_page(self, kind, title, html='', page_name=None, parent=None, auth_token=None, **kwargs)
CreateWebAttachment = create_webattachment(self, src, content_type, title, parent, description=None, auth_token=None, **kwargs)
DownloadAttachment = download_attachment(self, uri_or_entry, file_path)
GetActivityFeed = get_activity_feed(self, uri=None, auth_token=None, **kwargs)
GetContentFeed = get_content_feed(self, uri=None, auth_token=None, **kwargs)
GetRevisionFeed = get_revision_feed(self, entry_or_uri_or_id, auth_token=None, **kwargs)
MakeActivityFeedUri = make_activity_feed_uri(self)
MakeContentFeedUri = make_content_feed_uri(self)
MakeRevisionFeedUri = make_revision_feed_uri(self)
UploadAttachment = upload_attachment(self, file_handle, parent, content_type=None, title=None, description=None, folder_name=None, auth_token=None, **kwargs)
__init__(self, site=None, domain=None, auth_token=None, **kwargs)
Constructs a new client for the Sites API.
 
Args:
  site: string (optional) Name (webspace) of the Google Site
  domain: string (optional) Domain of the (Google Apps hosted) Site.
      If no domain is given, the Site is assumed to be a consumer Google
      Site, in which case the value 'site' is used.
  auth_token: (optional) gdata.gauth.ClientLoginToken, AuthSubToken, or
      OAuthToken which authorizes this client to edit the user's data.
  kwargs: The other parameters to pass to gdata.client.GDClient
      constructor.
create_page(self, kind, title, html='', page_name=None, parent=None, auth_token=None, **kwargs)
Creates a new page (specified by kind) on a Google Site.
 
Args:
  kind: string The type of page/item to create. For example, webpage,
      listpage, comment, announcementspage, filecabinet, etc. The full list
      of supported kinds can be found in gdata.sites.gdata.SUPPORT_KINDS.
  title: string Title for the page.
  html: string (optional) XHTML for the page's content body.
  page_name: string (optional) The URL page name to set. If not set, the
      title will be normalized and used as the page's URL path.
  parent: string or gdata.sites.data.ContentEntry (optional) The parent
      entry or parent link url to create the page under.
  auth_token: (optional) gdata.gauth.ClientLoginToken, AuthSubToken, or
      OAuthToken which authorizes this client to edit the user's data.
  kwargs: Other parameters to pass to gdata.client.post().
 
Returns:
  gdata.sites.data.ContentEntry of the created page.
create_webattachment(self, src, content_type, title, parent, description=None, auth_token=None, **kwargs)
Creates a new webattachment within a filecabinet.
 
Args:
  src: string The url of the web attachment.
  content_type: string The MIME type of the web attachment.
  title: string The title to name the web attachment.
  parent: string or gdata.sites.data.ContentEntry (optional) The
      parent entry or url of the filecabinet to create the attachment under.
  description: string (optional) A summary/description for the attachment.
  auth_token: (optional) gdata.gauth.ClientLoginToken, AuthSubToken, or
      OAuthToken which authorizes this client to edit the user's data.
  kwargs: Other parameters to pass to gdata.client.post().
 
Returns:
  gdata.sites.data.ContentEntry of the created page.
download_attachment(self, uri_or_entry, file_path)
Downloads an attachment file to disk.
 
Args:
  uri_or_entry: string The full URL to download the file from.
  file_path: string The full path to save the file to.
 
Raises:
  gdata.client.RequestError: on error response from server.
get_activity_feed(self, uri=None, auth_token=None, **kwargs)
Retrieves the activity feed containing recent Site activity.
 
Args:
  uri: string (optional) A full URI to query the Activity feed.
  auth_token: (optional) gdata.gauth.ClientLoginToken, AuthSubToken, or
      OAuthToken which authorizes this client to edit the user's data.
  kwargs: Other parameters to pass to get_feed().
 
Returns:
  gdata.sites.data.ActivityFeed
get_content_feed(self, uri=None, auth_token=None, **kwargs)
Retrieves the content feed containing the current state of site.
 
Args:
  uri: string (optional) A full URI to query the Content feed with.
  auth_token: (optional) gdata.gauth.ClientLoginToken, AuthSubToken, or
      OAuthToken which authorizes this client to edit the user's data.
  kwargs: Other parameters to pass to get_feed().
 
Returns:
  gdata.sites.data.ContentFeed
get_revision_feed(self, entry_or_uri_or_id, auth_token=None, **kwargs)
Retrieves the revision feed containing the revision history for a node.
 
Args:
  entry_or_uri_or_id: string or gdata.sites.data.SiteEntry A full URI,
      entry node ID, or entry object of the entry to retrieve revision
      information for.
  auth_token: (optional) gdata.gauth.ClientLoginToken, AuthSubToken, or
      OAuthToken which authorizes this client to edit the user's data.
  kwargs: Other parameters to pass to get_feed().
 
Returns:
  gdata.sites.data.RevisionFeed
make_activity_feed_uri(self)
make_content_feed_uri(self)
make_revision_feed_uri(self)
upload_attachment(self, file_handle, parent, content_type=None, title=None, description=None, folder_name=None, auth_token=None, **kwargs)
Uploads an attachment to a parent page.
 
Args:
  file_handle: MediaSource or string A gdata.data.MediaSource object
      containing the file to be uploaded or the full path name to the
      file on disk.
  parent: gdata.sites.data.ContentEntry or string The parent page to
      upload the file to or the full URI of the entry's self link.
  content_type: string (optional) The MIME type of the file
      (e.g 'application/pdf'). This should be provided if file is not a
      MediaSource object.
  title: string (optional) The title to name the attachment. If not
      included, the filepath or media source's filename is used.
  description: string (optional) A summary/description for the attachment.
  folder_name: string (optional) The name of an existing folder to upload
      the attachment to. This only applies when the parent parameter points
      to a filecabinet entry.
  auth_token: (optional) gdata.gauth.ClientLoginToken, AuthSubToken, or
      OAuthToken which authorizes this client to edit the user's data.
  kwargs: Other parameters to pass to __upload().
 
Returns:
  A gdata.sites.data.ContentEntry containing information about the created
  attachment.

Data and other attributes defined here:
api_version = '1'
auth_service = 'jotspot'
domain = 'site'
host = 'sites.google.com'

Methods inherited from gdata.client.GDClient:
ClientLogin = client_login(self, email, password, source, service=None, account_type='HOSTED_OR_GOOGLE', auth_url='https://www.google.com/accounts/ClientLogin', captcha_token=None, captcha_response=None)
Delete = delete(self, entry_or_uri, auth_token=None, force=False, **kwargs)
GetAccessToken = get_access_token(self, request_token, url='https://www.google.com/accounts/OAuthGetAccessToken')
Exchanges an authorized OAuth request token for an access token.
 
Contacts the Google OAuth server to upgrade a previously authorized
request token. Once the request token is upgraded to an access token,
the access token may be used to access the user's data.
 
For more details, see the Google Accounts OAuth documentation:
http://code.google.com/apis/accounts/docs/OAuth.html#AccessToken
 
Args:
  request_token: An OAuth token which has been authorized by the user.
  url: (optional) The URL to which the upgrade request should be sent.
      Defaults to: https://www.google.com/accounts/OAuthAuthorizeToken
GetEntry = get_entry(self, uri, auth_token=None, converter=None, desired_class=<class 'gdata.data.GDEntry'>, **kwargs)
GetFeed = get_feed(self, uri, auth_token=None, converter=None, desired_class=<class 'gdata.data.GDFeed'>, **kwargs)
GetNext = get_next(self, feed, auth_token=None, converter=None, desired_class=None, **kwargs)
Fetches the next set of results from the feed. 
 
When requesting a feed, the number of entries returned is capped at a
service specific default limit (often 25 entries). You can specify your
own entry-count cap using the max-results URL query parameter. If there
are more results than could fit under max-results, the feed will contain
a next link. This method performs a GET against this next results URL.
 
Returns:
  A new feed object containing the next set of entries in this feed.
GetOAuthToken = get_oauth_token(self, scopes, next, consumer_key, consumer_secret=None, rsa_private_key=None, url='https://www.google.com/accounts/OAuthGetRequestToken')
Obtains an OAuth request token to allow the user to authorize this app.
 
Once this client has a request token, the user can authorize the request
token by visiting the authorization URL in their browser. After being
redirected back to this app at the 'next' URL, this app can then exchange
the authorized request token for an access token.
 
For more information see the documentation on Google Accounts with OAuth:
http://code.google.com/apis/accounts/docs/OAuth.html#AuthProcess
 
Args:
  scopes: list of strings or atom.http_core.Uri objects which specify the
      URL prefixes which this app will be accessing. For example, to access
      the Google Calendar API, you would want to use scopes:
      ['https://www.google.com/calendar/feeds/',
       'http://www.google.com/calendar/feeds/']
  next: str or atom.http_core.Uri object, The URL which the user's browser
      should be sent to after they authorize access to their data. This
      should be a URL in your application which will read the token
      information from the URL and upgrade the request token to an access
      token.
  consumer_key: str This is the identifier for this application which you
      should have received when you registered your application with Google
      to use OAuth.
  consumer_secret: str (optional) The shared secret between your app and
      Google which provides evidence that this request is coming from you
      application and not another app. If present, this libraries assumes
      you want to use an HMAC signature to verify requests. Keep this data
      a secret.
  rsa_private_key: str (optional) The RSA private key which is used to 
      generate a digital signature which is checked by Google's server. If
      present, this library assumes that you want to use an RSA signature
      to verify requests. Keep this data a secret.
  url: The URL to which a request for a token should be made. The default
      is Google's OAuth request token provider.
ModifyRequest = modify_request(self, http_request)
Adds or changes request before making the HTTP request.
 
This client will add the API version if it is specified. 
Subclasses may override this method to add their own request 
modifications before the request is made.
Post = post(self, entry, uri, auth_token=None, converter=None, desired_class=None, **kwargs)
Request = request(self, method=None, uri=None, auth_token=None, http_request=None, converter=None, desired_class=None, redirects_remaining=4, **kwargs)
Make an HTTP request to the server.
 
See also documentation for atom.client.AtomPubClient.request.
 
If a 302 redirect is sent from the server to the client, this client
assumes that the redirect is in the form used by the Google Calendar API.
The same request URI and method will be used as in the original request,
but a gsessionid URL parameter will be added to the request URI with
the value provided in the server's 302 redirect response. If the 302
redirect is not in the format specified by the Google Calendar API, a
RedirectError will be raised containing the body of the server's
response.
 
The method calls the client's modify_request method to make any changes
required by the client before the request is made. For example, a
version 2 client could add a GData-Version: 2 header to the request in
its modify_request method.
 
Args:
  method: str The HTTP verb for this request, usually 'GET', 'POST', 
          'PUT', or 'DELETE'
  uri: atom.http_core.Uri, str, or unicode The URL being requested.
  auth_token: An object which sets the Authorization HTTP header in its
              modify_request method. Recommended classes include 
              gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken
              among others.
  http_request: (optional) atom.http_core.HttpRequest
  converter: function which takes the body of the response as it's only
             argument and returns the desired object.
  desired_class: class descended from atom.core.XmlElement to which a
                 successful response should be converted. If there is no
                 converter function specified (converter=None) then the
                 desired_class will be used in calling the
                 atom.core.parse function. If neither
                 the desired_class nor the converter is specified, an
                 HTTP reponse object will be returned.
  redirects_remaining: (optional) int, if this number is 0 and the
                       server sends a 302 redirect, the request method
                       will raise an exception. This parameter is used in
                       recursive request calls to avoid an infinite loop.
 
Any additional arguments are passed through to 
atom.client.AtomPubClient.request.
 
Returns:
  An HTTP response object (see atom.http_core.HttpResponse for a
  description of the object's interface) if no converter was
  specified and no desired_class was specified. If a converter function
  was provided, the results of calling the converter are returned. If no
  converter was specified but a desired_class was provided, the response
  body will be converted to the class using 
  atom.core.parse.
RequestClientLoginToken = request_client_login_token(self, email, password, source, service=None, account_type='HOSTED_OR_GOOGLE', auth_url=<atom.http_core.Uri object at 0xc44b90>, captcha_token=None, captcha_response=None)
Update = update(self, entry, auth_token=None, force=False, **kwargs)
Edits the entry on the server by sending the XML for this entry.
 
Performs a PUT and converts the response to a new entry object with a
matching class to the entry passed in.
 
Args:
  entry:
  auth_token:
  force: boolean stating whether an update should be forced. Defaults to
         False. Normally, if a change has been made since the passed in
         entry was obtained, the server will not overwrite the entry since
         the changes were based on an obsolete version of the entry.
         Setting force to True will cause the update to silently
         overwrite whatever version is present.
 
Returns:
  A new Entry object of a matching type to the entry which was passed in.
UpgradeToken = upgrade_token(self, token=None, url=<atom.http_core.Uri object at 0xc44bd0>)
Asks the Google auth server for a multi-use AuthSub token.
 
For details on AuthSub, see:
http://code.google.com/apis/accounts/docs/AuthSub.html
 
Args:
  token: gdata.gauth.AuthSubToken or gdata.gauth.SecureAuthSubToken
      (optional) If no token is passed in, the client's auth_token member
      is used to request the new token. The token object will be modified
      to contain the new session token string.
  url: str or atom.http_core.Uri (optional) The URL to which the token
      upgrade request should be sent. Defaults to: 
      https://www.google.com/accounts/AuthSubSessionToken
 
Returns:
  The upgraded gdata.gauth.AuthSubToken object.
client_login(self, email, password, source, service=None, account_type='HOSTED_OR_GOOGLE', auth_url='https://www.google.com/accounts/ClientLogin', captcha_token=None, captcha_response=None)
delete(self, entry_or_uri, auth_token=None, force=False, **kwargs)
get_access_token(self, request_token, url='https://www.google.com/accounts/OAuthGetAccessToken')
Exchanges an authorized OAuth request token for an access token.
 
Contacts the Google OAuth server to upgrade a previously authorized
request token. Once the request token is upgraded to an access token,
the access token may be used to access the user's data.
 
For more details, see the Google Accounts OAuth documentation:
http://code.google.com/apis/accounts/docs/OAuth.html#AccessToken
 
Args:
  request_token: An OAuth token which has been authorized by the user.
  url: (optional) The URL to which the upgrade request should be sent.
      Defaults to: https://www.google.com/accounts/OAuthAuthorizeToken
get_entry(self, uri, auth_token=None, converter=None, desired_class=<class 'gdata.data.GDEntry'>, **kwargs)
get_feed(self, uri, auth_token=None, converter=None, desired_class=<class 'gdata.data.GDFeed'>, **kwargs)
get_next(self, feed, auth_token=None, converter=None, desired_class=None, **kwargs)
Fetches the next set of results from the feed. 
 
When requesting a feed, the number of entries returned is capped at a
service specific default limit (often 25 entries). You can specify your
own entry-count cap using the max-results URL query parameter. If there
are more results than could fit under max-results, the feed will contain
a next link. This method performs a GET against this next results URL.
 
Returns:
  A new feed object containing the next set of entries in this feed.
get_oauth_token(self, scopes, next, consumer_key, consumer_secret=None, rsa_private_key=None, url='https://www.google.com/accounts/OAuthGetRequestToken')
Obtains an OAuth request token to allow the user to authorize this app.
 
Once this client has a request token, the user can authorize the request
token by visiting the authorization URL in their browser. After being
redirected back to this app at the 'next' URL, this app can then exchange
the authorized request token for an access token.
 
For more information see the documentation on Google Accounts with OAuth:
http://code.google.com/apis/accounts/docs/OAuth.html#AuthProcess
 
Args:
  scopes: list of strings or atom.http_core.Uri objects which specify the
      URL prefixes which this app will be accessing. For example, to access
      the Google Calendar API, you would want to use scopes:
      ['https://www.google.com/calendar/feeds/',
       'http://www.google.com/calendar/feeds/']
  next: str or atom.http_core.Uri object, The URL which the user's browser
      should be sent to after they authorize access to their data. This
      should be a URL in your application which will read the token
      information from the URL and upgrade the request token to an access
      token.
  consumer_key: str This is the identifier for this application which you
      should have received when you registered your application with Google
      to use OAuth.
  consumer_secret: str (optional) The shared secret between your app and
      Google which provides evidence that this request is coming from you
      application and not another app. If present, this libraries assumes
      you want to use an HMAC signature to verify requests. Keep this data
      a secret.
  rsa_private_key: str (optional) The RSA private key which is used to 
      generate a digital signature which is checked by Google's server. If
      present, this library assumes that you want to use an RSA signature
      to verify requests. Keep this data a secret.
  url: The URL to which a request for a token should be made. The default
      is Google's OAuth request token provider.
modify_request(self, http_request)
Adds or changes request before making the HTTP request.
 
This client will add the API version if it is specified. 
Subclasses may override this method to add their own request 
modifications before the request is made.
post(self, entry, uri, auth_token=None, converter=None, desired_class=None, **kwargs)
request(self, method=None, uri=None, auth_token=None, http_request=None, converter=None, desired_class=None, redirects_remaining=4, **kwargs)
Make an HTTP request to the server.
 
See also documentation for atom.client.AtomPubClient.request.
 
If a 302 redirect is sent from the server to the client, this client
assumes that the redirect is in the form used by the Google Calendar API.
The same request URI and method will be used as in the original request,
but a gsessionid URL parameter will be added to the request URI with
the value provided in the server's 302 redirect response. If the 302
redirect is not in the format specified by the Google Calendar API, a
RedirectError will be raised containing the body of the server's
response.
 
The method calls the client's modify_request method to make any changes
required by the client before the request is made. For example, a
version 2 client could add a GData-Version: 2 header to the request in
its modify_request method.
 
Args:
  method: str The HTTP verb for this request, usually 'GET', 'POST', 
          'PUT', or 'DELETE'
  uri: atom.http_core.Uri, str, or unicode The URL being requested.
  auth_token: An object which sets the Authorization HTTP header in its
              modify_request method. Recommended classes include 
              gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken
              among others.
  http_request: (optional) atom.http_core.HttpRequest
  converter: function which takes the body of the response as it's only
             argument and returns the desired object.
  desired_class: class descended from atom.core.XmlElement to which a
                 successful response should be converted. If there is no
                 converter function specified (converter=None) then the
                 desired_class will be used in calling the
                 atom.core.parse function. If neither
                 the desired_class nor the converter is specified, an
                 HTTP reponse object will be returned.
  redirects_remaining: (optional) int, if this number is 0 and the
                       server sends a 302 redirect, the request method
                       will raise an exception. This parameter is used in
                       recursive request calls to avoid an infinite loop.
 
Any additional arguments are passed through to 
atom.client.AtomPubClient.request.
 
Returns:
  An HTTP response object (see atom.http_core.HttpResponse for a
  description of the object's interface) if no converter was
  specified and no desired_class was specified. If a converter function
  was provided, the results of calling the converter are returned. If no
  converter was specified but a desired_class was provided, the response
  body will be converted to the class using 
  atom.core.parse.
request_client_login_token(self, email, password, source, service=None, account_type='HOSTED_OR_GOOGLE', auth_url=<atom.http_core.Uri object at 0xc44b90>, captcha_token=None, captcha_response=None)
update(self, entry, auth_token=None, force=False, **kwargs)
Edits the entry on the server by sending the XML for this entry.
 
Performs a PUT and converts the response to a new entry object with a
matching class to the entry passed in.
 
Args:
  entry:
  auth_token:
  force: boolean stating whether an update should be forced. Defaults to
         False. Normally, if a change has been made since the passed in
         entry was obtained, the server will not overwrite the entry since
         the changes were based on an obsolete version of the entry.
         Setting force to True will cause the update to silently
         overwrite whatever version is present.
 
Returns:
  A new Entry object of a matching type to the entry which was passed in.
upgrade_token(self, token=None, url=<atom.http_core.Uri object at 0xc44bd0>)
Asks the Google auth server for a multi-use AuthSub token.
 
For details on AuthSub, see:
http://code.google.com/apis/accounts/docs/AuthSub.html
 
Args:
  token: gdata.gauth.AuthSubToken or gdata.gauth.SecureAuthSubToken
      (optional) If no token is passed in, the client's auth_token member
      is used to request the new token. The token object will be modified
      to contain the new session token string.
  url: str or atom.http_core.Uri (optional) The URL to which the token
      upgrade request should be sent. Defaults to: 
      https://www.google.com/accounts/AuthSubSessionToken
 
Returns:
  The upgraded gdata.gauth.AuthSubToken object.

Data and other attributes inherited from gdata.client.GDClient:
auth_scopes = None

Methods inherited from atom.client.AtomPubClient:
Get = get(self, uri=None, auth_token=None, http_request=None, **kwargs)
Put = put(self, uri=None, data=None, auth_token=None, http_request=None, **kwargs)
get(self, uri=None, auth_token=None, http_request=None, **kwargs)
put(self, uri=None, data=None, auth_token=None, http_request=None, **kwargs)

Data descriptors inherited from atom.client.AtomPubClient:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from atom.client.AtomPubClient:
auth_token = None
ssl = False

 
Data
        ACTIVITY_FEED_TEMPLATE = '/feeds/activity/%s/%s/'
CONTENT_FEED_TEMPLATE = '/feeds/content/%s/%s/'
REVISION_FEED_TEMPLATE = '/feeds/revision/%s/%s/'
__author__ = 'e.bidelman (Eric Bidelman)'

 
Author
        e.bidelman (Eric Bidelman)