988 lines
75 KiB
HTML
988 lines
75 KiB
HTML
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: module oauth2client.appengine</title>
|
|
</head><body bgcolor="#f0f0f8">
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
<tr bgcolor="#7799ee">
|
|
<td valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="oauth2client.html"><font color="#ffffff">oauth2client</font></a>.appengine</strong></big></big></font></td
|
|
><td align=right valign=bottom
|
|
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/appengine.py">/usr/local/google/home/jcgregorio/projects/apiclient/oauth2client/appengine.py</a></font></td></tr></table>
|
|
<p><tt>Utilities for Google App Engine<br>
|
|
<br>
|
|
Utilities for making it easier to use OAuth 2.0 on Google App Engine.</tt></p>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#aa55cc">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
|
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="google.appengine.api.app_identity.app_identity.html">google.appengine.api.app_identity.app_identity</a><br>
|
|
<a href="base64.html">base64</a><br>
|
|
<a href="google.appengine.ext.db.html">google.appengine.ext.db</a><br>
|
|
</td><td width="25%" valign=top><a href="httplib2.html">httplib2</a><br>
|
|
<a href="google.appengine.api.memcache.html">google.appengine.api.memcache</a><br>
|
|
<a href="pickle.html">pickle</a><br>
|
|
</td><td width="25%" valign=top><a href="simplejson.html">simplejson</a><br>
|
|
<a href="time.html">time</a><br>
|
|
<a href="google.appengine.api.users.html">google.appengine.api.users</a><br>
|
|
</td><td width="25%" valign=top><a href="google.appengine.ext.webapp.html">google.appengine.ext.webapp</a><br>
|
|
</td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ee77aa">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl>
|
|
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="oauth2client.appengine.html#OAuth2Decorator">OAuth2Decorator</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="google.appengine.ext.db.html#Model">google.appengine.ext.db.Model</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="oauth2client.appengine.html#CredentialsModel">CredentialsModel</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="oauth2client.appengine.html#CredentialsProperty">CredentialsProperty</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="oauth2client.appengine.html#FlowProperty">FlowProperty</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="google.appengine.ext.webapp.html#RequestHandler">google.appengine.ext.webapp.RequestHandler</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="oauth2client.appengine.html#OAuth2Handler">OAuth2Handler</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="oauth2client.client.html#AssertionCredentials">oauth2client.client.AssertionCredentials</a>(<a href="oauth2client.client.html#OAuth2Credentials">oauth2client.client.OAuth2Credentials</a>)
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="oauth2client.appengine.html#AppAssertionCredentials">AppAssertionCredentials</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="oauth2client.client.html#Storage">oauth2client.client.Storage</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="oauth2client.appengine.html#StorageByKeyName">StorageByKeyName</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
</dl>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="AppAssertionCredentials">class <strong>AppAssertionCredentials</strong></a>(<a href="oauth2client.client.html#AssertionCredentials">oauth2client.client.AssertionCredentials</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Credentials <a href="__builtin__.html#object">object</a> for App Engine Assertion Grants<br>
|
|
<br>
|
|
This <a href="__builtin__.html#object">object</a> will allow an App Engine application to identify itself to Google<br>
|
|
and other OAuth 2.0 servers that can verify assertions. It can be used for<br>
|
|
the purpose of accessing data stored under an account assigned to the App<br>
|
|
Engine application itself. The algorithm used for generating the assertion is<br>
|
|
the Signed JSON Web Token (JWT) algorithm. Additional details can be found at<br>
|
|
the following link:<br>
|
|
<br>
|
|
<a href="http://self-issued.info/docs/draft-jones-json-web-token.html">http://self-issued.info/docs/draft-jones-json-web-token.html</a><br>
|
|
<br>
|
|
This credential does not require a flow to instantiate because it represents<br>
|
|
a two legged flow, and therefore has all of the required information to<br>
|
|
generate and refresh its own access tokens.<br>
|
|
<br>
|
|
AssertionFlowCredentials objects may be safely pickled and unpickled.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="oauth2client.appengine.html#AppAssertionCredentials">AppAssertionCredentials</a></dd>
|
|
<dd><a href="oauth2client.client.html#AssertionCredentials">oauth2client.client.AssertionCredentials</a></dd>
|
|
<dd><a href="oauth2client.client.html#OAuth2Credentials">oauth2client.client.OAuth2Credentials</a></dd>
|
|
<dd><a href="oauth2client.client.html#Credentials">oauth2client.client.Credentials</a></dd>
|
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="AppAssertionCredentials-__init__"><strong>__init__</strong></a>(self, scope, audience<font color="#909090">='https://accounts.google.com/o/oauth2/token'</font>, assertion_type<font color="#909090">='http://oauth.net/grant_type/jwt/1.0/bearer'</font>, token_uri<font color="#909090">='https://accounts.google.com/o/oauth2/token'</font>, **kwargs)</dt><dd><tt>Constructor for <a href="#AppAssertionCredentials">AppAssertionCredentials</a><br>
|
|
<br>
|
|
Args:<br>
|
|
scope: string, scope of the credentials being requested.<br>
|
|
audience: string, The audience, or verifier of the assertion. For<br>
|
|
convenience defaults to Google's audience.<br>
|
|
assertion_type: string, Type name that will identify the format of the<br>
|
|
assertion string. For convience, defaults to the JSON Web Token (JWT)<br>
|
|
assertion type string.<br>
|
|
token_uri: string, URI for token endpoint. For convenience<br>
|
|
defaults to Google's endpoints but any OAuth 2.0 provider can be used.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Class methods defined here:<br>
|
|
<dl><dt><a name="AppAssertionCredentials-from_json"><strong>from_json</strong></a>(cls, json)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="oauth2client.client.html#OAuth2Credentials">oauth2client.client.OAuth2Credentials</a>:<br>
|
|
<dl><dt><a name="AppAssertionCredentials-__getstate__"><strong>__getstate__</strong></a>(self)</dt><dd><tt>Trim the state down to something that can be pickled.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="AppAssertionCredentials-__setstate__"><strong>__setstate__</strong></a>(self, state)</dt><dd><tt>Reconstitute the state of the <a href="__builtin__.html#object">object</a> from being pickled.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="AppAssertionCredentials-authorize"><strong>authorize</strong></a>(self, http)</dt><dd><tt>Authorize an httplib2.Http instance with these credentials.<br>
|
|
<br>
|
|
Args:<br>
|
|
http: An instance of httplib2.Http<br>
|
|
or something that acts like it.<br>
|
|
<br>
|
|
Returns:<br>
|
|
A modified instance of http that was passed in.<br>
|
|
<br>
|
|
Example:<br>
|
|
<br>
|
|
h = httplib2.Http()<br>
|
|
h = credentials.<a href="#AppAssertionCredentials-authorize">authorize</a>(h)<br>
|
|
<br>
|
|
You can't create a new OAuth subclass of httplib2.Authenication<br>
|
|
because it never gets passed the absolute URI, which is needed for<br>
|
|
signing. So instead we have to overload 'request' with a closure<br>
|
|
that adds in the Authorization header and then calls the original<br>
|
|
version of 'request()'.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="AppAssertionCredentials-set_store"><strong>set_store</strong></a>(self, store)</dt><dd><tt>Set the <a href="oauth2client.client.html#Storage">Storage</a> for the credential.<br>
|
|
<br>
|
|
Args:<br>
|
|
store: <a href="oauth2client.client.html#Storage">Storage</a>, an implementation of Stroage <a href="__builtin__.html#object">object</a>.<br>
|
|
This is needed to store the latest access_token if it<br>
|
|
has expired and been refreshed. This implementation uses<br>
|
|
locking to check for updates before updating the<br>
|
|
access_token.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="AppAssertionCredentials-to_json"><strong>to_json</strong></a>(self)</dt></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="oauth2client.client.html#OAuth2Credentials">oauth2client.client.OAuth2Credentials</a>:<br>
|
|
<dl><dt><strong>access_token_expired</strong></dt>
|
|
<dd><tt>True if the credential is expired or invalid.<br>
|
|
<br>
|
|
If the token_expiry isn't set, we assume the token doesn't expire.</tt></dd>
|
|
</dl>
|
|
<hr>
|
|
Class methods inherited from <a href="oauth2client.client.html#Credentials">oauth2client.client.Credentials</a>:<br>
|
|
<dl><dt><a name="AppAssertionCredentials-new_from_json"><strong>new_from_json</strong></a>(cls, s)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Utility class method to instantiate a Credentials subclass from a JSON<br>
|
|
representation produced by <a href="#AppAssertionCredentials-to_json">to_json</a>().<br>
|
|
<br>
|
|
Args:<br>
|
|
s: string, JSON from <a href="#AppAssertionCredentials-to_json">to_json</a>().<br>
|
|
<br>
|
|
Returns:<br>
|
|
An instance of the subclass of Credentials that was serialized with<br>
|
|
<a href="#AppAssertionCredentials-to_json">to_json</a>().</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="oauth2client.client.html#Credentials">oauth2client.client.Credentials</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
<hr>
|
|
Data and other attributes inherited from <a href="oauth2client.client.html#Credentials">oauth2client.client.Credentials</a>:<br>
|
|
<dl><dt><strong>NON_SERIALIZED_MEMBERS</strong> = ['store']</dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="CredentialsModel">class <strong>CredentialsModel</strong></a>(<a href="google.appengine.ext.db.html#Model">google.appengine.ext.db.Model</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt><a href="oauth2client.client.html#Storage">Storage</a> for OAuth 2.0 Credentials<br>
|
|
<br>
|
|
<a href="oauth2client.client.html#Storage">Storage</a> of the model is keyed by the user.user_id().<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="oauth2client.appengine.html#CredentialsModel">CredentialsModel</a></dd>
|
|
<dd><a href="google.appengine.ext.db.html#Model">google.appengine.ext.db.Model</a></dd>
|
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>credentials</strong></dt>
|
|
<dd><tt>App Engine datastore Property for Credentials.<br>
|
|
<br>
|
|
Utility property that allows easy storage and retrieval of<br>
|
|
oath2client.Credentials</tt></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods inherited from <a href="google.appengine.ext.db.html#Model">google.appengine.ext.db.Model</a>:<br>
|
|
<dl><dt><a name="CredentialsModel-__init__"><strong>__init__</strong></a>(self, parent<font color="#909090">=None</font>, key_name<font color="#909090">=None</font>, _app<font color="#909090">=None</font>, _from_entity<font color="#909090">=False</font>, **kwds)</dt><dd><tt>Creates a new instance of this model.<br>
|
|
<br>
|
|
To create a new entity, you instantiate a model and then call <a href="#CredentialsModel-put">put</a>(),<br>
|
|
which saves the entity to the datastore:<br>
|
|
<br>
|
|
person = Person()<br>
|
|
person.name = 'Bret'<br>
|
|
person.<a href="#CredentialsModel-put">put</a>()<br>
|
|
<br>
|
|
You can initialize properties in the model in the constructor with keyword<br>
|
|
arguments:<br>
|
|
<br>
|
|
person = Person(name='Bret')<br>
|
|
<br>
|
|
We initialize all other properties to the default value (as defined by the<br>
|
|
properties in the model definition) if they are not provided in the<br>
|
|
constructor.<br>
|
|
<br>
|
|
Args:<br>
|
|
parent: Parent instance for this instance or None, indicating a top-<br>
|
|
level instance.<br>
|
|
key_name: Name for new model instance.<br>
|
|
_from_entity: Intentionally undocumented.<br>
|
|
kwds: Keyword arguments mapping to properties of model. Also:<br>
|
|
key: Key instance for this instance, if provided makes parent and<br>
|
|
key_name redundant (they do not need to be set but if they are<br>
|
|
they must match the key).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-delete"><strong>delete</strong></a>(self, **kwargs)</dt><dd><tt>Deletes this entity from the datastore.<br>
|
|
<br>
|
|
Args:<br>
|
|
config: datastore_rpc.Configuration to use for this request.<br>
|
|
<br>
|
|
Raises:<br>
|
|
TransactionFailedError if the data could not be committed.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-dynamic_properties"><strong>dynamic_properties</strong></a>(self)</dt><dd><tt>Returns a list of all dynamic properties defined for instance.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-has_key"><strong>has_key</strong></a>(self)</dt><dd><tt>Determine if this model instance has a complete key.<br>
|
|
<br>
|
|
When not using a fully self-assigned Key, ids are not assigned until the<br>
|
|
data is saved to the Datastore, but instances with a key name always have<br>
|
|
a full key.<br>
|
|
<br>
|
|
Returns:<br>
|
|
True if the <a href="__builtin__.html#object">object</a> has been persisted to the datastore or has a key<br>
|
|
or has a key_name, otherwise False.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-instance_properties"><strong>instance_properties</strong></a>(self)</dt><dd><tt>Alias for dyanmic_properties.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-is_saved"><strong>is_saved</strong></a>(self)</dt><dd><tt>Determine if entity is persisted in the datastore.<br>
|
|
<br>
|
|
New instances of <a href="google.appengine.ext.db.html#Model">Model</a> do not start out saved in the data. Objects which<br>
|
|
are saved to or loaded from the Datastore will have a True saved state.<br>
|
|
<br>
|
|
Returns:<br>
|
|
True if <a href="__builtin__.html#object">object</a> has been persisted to the datastore, otherwise False.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-key"><strong>key</strong></a>(self)</dt><dd><tt>Unique key for this entity.<br>
|
|
<br>
|
|
This property is only available if this entity is already stored in the<br>
|
|
datastore or if it has a full key, so it is available if this entity was<br>
|
|
fetched returned from a query, or after <a href="#CredentialsModel-put">put</a>() is called the first time<br>
|
|
for new entities, or if a complete key was given when constructed.<br>
|
|
<br>
|
|
Returns:<br>
|
|
Datastore key of persisted entity.<br>
|
|
<br>
|
|
Raises:<br>
|
|
NotSavedError when entity is not persistent.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-parent"><strong>parent</strong></a>(self)</dt><dd><tt>Get the parent of the model instance.<br>
|
|
<br>
|
|
Returns:<br>
|
|
Parent of contained entity or parent provided in constructor, None if<br>
|
|
instance has no parent.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-parent_key"><strong>parent_key</strong></a>(self)</dt><dd><tt>Get the parent's key.<br>
|
|
<br>
|
|
This method is useful for avoiding a potential fetch from the datastore<br>
|
|
but still get information about the instances parent.<br>
|
|
<br>
|
|
Returns:<br>
|
|
Parent key of entity, None if there is no parent.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-put"><strong>put</strong></a>(self, **kwargs)</dt><dd><tt>Writes this model instance to the datastore.<br>
|
|
<br>
|
|
If this instance is new, we add an entity to the datastore.<br>
|
|
Otherwise, we update this instance, and the key will remain the<br>
|
|
same.<br>
|
|
<br>
|
|
Args:<br>
|
|
config: datastore_rpc.Configuration to use for this request.<br>
|
|
<br>
|
|
Returns:<br>
|
|
The key of the instance (either the existing key or a new key).<br>
|
|
<br>
|
|
Raises:<br>
|
|
TransactionFailedError if the data could not be committed.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-save"><strong>save</strong></a> = put(self, **kwargs)</dt><dd><tt>Writes this model instance to the datastore.<br>
|
|
<br>
|
|
If this instance is new, we add an entity to the datastore.<br>
|
|
Otherwise, we update this instance, and the key will remain the<br>
|
|
same.<br>
|
|
<br>
|
|
Args:<br>
|
|
config: datastore_rpc.Configuration to use for this request.<br>
|
|
<br>
|
|
Returns:<br>
|
|
The key of the instance (either the existing key or a new key).<br>
|
|
<br>
|
|
Raises:<br>
|
|
TransactionFailedError if the data could not be committed.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-to_xml"><strong>to_xml</strong></a>(self, _entity_class<font color="#909090">=<class 'google.appengine.api.datastore.Entity'></font>)</dt><dd><tt>Generate an XML representation of this model instance.<br>
|
|
<br>
|
|
atom and gd:namespace properties are converted to XML according to their<br>
|
|
respective schemas. For more information, see:<br>
|
|
<br>
|
|
<a href="http://www.atomenabled.org/developers/syndication/">http://www.atomenabled.org/developers/syndication/</a><br>
|
|
<a href="http://code.google.com/apis/gdata/common-elements.html">http://code.google.com/apis/gdata/common-elements.html</a></tt></dd></dl>
|
|
|
|
<hr>
|
|
Class methods inherited from <a href="google.appengine.ext.db.html#Model">google.appengine.ext.db.Model</a>:<br>
|
|
<dl><dt><a name="CredentialsModel-all"><strong>all</strong></a>(cls, **kwds)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Returns a query over all instances of this model from the datastore.<br>
|
|
<br>
|
|
Returns:<br>
|
|
Query that will retrieve all instances from entity collection.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-entity_type"><strong>entity_type</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Soon to be removed alias for kind.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-fields"><strong>fields</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Soon to be removed alias for properties.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-from_entity"><strong>from_entity</strong></a>(cls, entity)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Converts the entity representation of this model to an instance.<br>
|
|
<br>
|
|
Converts datastore.Entity instance to an instance of cls.<br>
|
|
<br>
|
|
Args:<br>
|
|
entity: Entity loaded directly from datastore.<br>
|
|
<br>
|
|
Raises:<br>
|
|
KindError when cls is incorrect model for entity.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-get"><strong>get</strong></a>(cls, keys, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Fetch instance from the datastore of a specific <a href="google.appengine.ext.db.html#Model">Model</a> type using key.<br>
|
|
<br>
|
|
We support Key objects and string keys (we convert them to Key objects<br>
|
|
automatically).<br>
|
|
<br>
|
|
Useful for ensuring that specific instance types are retrieved from the<br>
|
|
datastore. It also helps that the source code clearly indicates what<br>
|
|
kind of <a href="__builtin__.html#object">object</a> is being retreived. Example:<br>
|
|
<br>
|
|
story = Story.<a href="#CredentialsModel-get">get</a>(story_key)<br>
|
|
<br>
|
|
Args:<br>
|
|
keys: Key within datastore entity collection to find; or string key;<br>
|
|
or list of Keys or string keys.<br>
|
|
config: datastore_rpc.Configuration to use for this request.<br>
|
|
<br>
|
|
Returns:<br>
|
|
If a single key was given: a <a href="google.appengine.ext.db.html#Model">Model</a> instance associated with key<br>
|
|
for provided class if it exists in the datastore, otherwise<br>
|
|
None; if a list of keys was given: a list whose items are either<br>
|
|
a <a href="google.appengine.ext.db.html#Model">Model</a> instance or None.<br>
|
|
<br>
|
|
Raises:<br>
|
|
KindError if any of the retreived objects are not instances of the<br>
|
|
type associated with call to 'get'.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-get_by_id"><strong>get_by_id</strong></a>(cls, ids, parent<font color="#909090">=None</font>, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Get instance of <a href="google.appengine.ext.db.html#Model">Model</a> class by id.<br>
|
|
<br>
|
|
Args:<br>
|
|
key_names: A single id or a list of ids.<br>
|
|
parent: Parent of instances to get. Can be a model or key.<br>
|
|
config: datastore_rpc.Configuration to use for this request.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-get_by_key_name"><strong>get_by_key_name</strong></a>(cls, key_names, parent<font color="#909090">=None</font>, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Get instance of <a href="google.appengine.ext.db.html#Model">Model</a> class by its key's name.<br>
|
|
<br>
|
|
Args:<br>
|
|
key_names: A single key-name or a list of key-names.<br>
|
|
parent: Parent of instances to get. Can be a model or key.<br>
|
|
config: datastore_rpc.Configuration to use for this request.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-get_or_insert"><strong>get_or_insert</strong></a>(cls, key_name, **kwds)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Transactionally retrieve or create an instance of <a href="google.appengine.ext.db.html#Model">Model</a> class.<br>
|
|
<br>
|
|
This acts much like the Python dictionary setdefault() method, where we<br>
|
|
first try to retrieve a <a href="google.appengine.ext.db.html#Model">Model</a> instance with the given key name and parent.<br>
|
|
If it's not present, then we create a new instance (using the *kwds<br>
|
|
supplied) and insert that with the supplied key name.<br>
|
|
<br>
|
|
Subsequent calls to this method with the same key_name and parent will<br>
|
|
always yield the same entity (though not the same actual <a href="__builtin__.html#object">object</a> instance),<br>
|
|
regardless of the *kwds supplied. If the specified entity has somehow<br>
|
|
been deleted separately, then the next call will create a new entity and<br>
|
|
return it.<br>
|
|
<br>
|
|
If the 'parent' keyword argument is supplied, it must be a <a href="google.appengine.ext.db.html#Model">Model</a> instance.<br>
|
|
It will be used as the parent of the new instance of this <a href="google.appengine.ext.db.html#Model">Model</a> class if<br>
|
|
one is created.<br>
|
|
<br>
|
|
This method is especially useful for having just one unique entity for<br>
|
|
a specific identifier. Insertion/retrieval is done transactionally, which<br>
|
|
guarantees uniqueness.<br>
|
|
<br>
|
|
Example usage:<br>
|
|
<br>
|
|
class WikiTopic(db.<a href="google.appengine.ext.db.html#Model">Model</a>):<br>
|
|
creation_date = db.DatetimeProperty(auto_now_add=True)<br>
|
|
body = db.TextProperty(required=True)<br>
|
|
<br>
|
|
# The first time through we'll create the new topic.<br>
|
|
wiki_word = 'CommonIdioms'<br>
|
|
topic = WikiTopic.<a href="#CredentialsModel-get_or_insert">get_or_insert</a>(wiki_word,<br>
|
|
body='This topic is totally new!')<br>
|
|
assert topic.<a href="#CredentialsModel-key">key</a>().name() == 'CommonIdioms'<br>
|
|
assert topic.body == 'This topic is totally new!'<br>
|
|
<br>
|
|
# The second time through will just retrieve the entity.<br>
|
|
overwrite_topic = WikiTopic.<a href="#CredentialsModel-get_or_insert">get_or_insert</a>(wiki_word,<br>
|
|
body='A totally different message!')<br>
|
|
assert topic.<a href="#CredentialsModel-key">key</a>().name() == 'CommonIdioms'<br>
|
|
assert topic.body == 'This topic is totally new!'<br>
|
|
<br>
|
|
Args:<br>
|
|
key_name: Key name to retrieve or create.<br>
|
|
**kwds: Keyword arguments to pass to the constructor of the model class<br>
|
|
if an instance for the specified key name does not already exist. If<br>
|
|
an instance with the supplied key_name and parent already exists, the<br>
|
|
rest of these arguments will be discarded.<br>
|
|
<br>
|
|
Returns:<br>
|
|
Existing instance of <a href="google.appengine.ext.db.html#Model">Model</a> class with the specified key_name and parent<br>
|
|
or a new one that has just been created.<br>
|
|
<br>
|
|
Raises:<br>
|
|
TransactionFailedError if the specified <a href="google.appengine.ext.db.html#Model">Model</a> instance could not be<br>
|
|
retrieved or created transactionally (due to high contention, etc).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-gql"><strong>gql</strong></a>(cls, query_string, *args, **kwds)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Returns a query using GQL query string.<br>
|
|
<br>
|
|
See appengine/ext/gql for more information about GQL.<br>
|
|
<br>
|
|
Args:<br>
|
|
query_string: properly formatted GQL query string with the<br>
|
|
'SELECT * FROM <entity>' part omitted<br>
|
|
*args: rest of the positional arguments used to bind numeric references<br>
|
|
in the query.<br>
|
|
**kwds: dictionary-based arguments (for named parameters).</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-kind"><strong>kind</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Returns the datastore kind we use for this model.<br>
|
|
<br>
|
|
We just use the name of the model for now, ignoring potential collisions.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsModel-properties"><strong>properties</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="google.appengine.ext.db.html#PropertiedClass">google.appengine.ext.db.PropertiedClass</a></font></font></dt><dd><tt>Returns a dictionary of all the properties defined for this model.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Static methods inherited from <a href="google.appengine.ext.db.html#Model">google.appengine.ext.db.Model</a>:<br>
|
|
<dl><dt><a name="CredentialsModel-__new__"><strong>__new__</strong></a>(*args, **unused_kwds)</dt><dd><tt>Allow subclasses to call <a href="#CredentialsModel-__new__">__new__</a>() with arguments.<br>
|
|
<br>
|
|
Do NOT list 'cls' as the first argument, or in the case when<br>
|
|
the 'unused_kwds' dictionary contains the key 'cls', the function<br>
|
|
will complain about multiple argument values for 'cls'.<br>
|
|
<br>
|
|
Raises:<br>
|
|
TypeError if there are no positional arguments.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="google.appengine.ext.db.html#Model">google.appengine.ext.db.Model</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
<hr>
|
|
Data and other attributes inherited from <a href="google.appengine.ext.db.html#Model">google.appengine.ext.db.Model</a>:<br>
|
|
<dl><dt><strong>__metaclass__</strong> = <class 'google.appengine.ext.db.PropertiedClass'><dd><tt>Meta-class for initializing <a href="google.appengine.ext.db.html#Model">Model</a> classes properties.<br>
|
|
<br>
|
|
Used for initializing Properties defined in the context of a model.<br>
|
|
By using a meta-class much of the configuration of a <a href="google.appengine.ext.db.html#Property">Property</a><br>
|
|
descriptor becomes implicit. By using this meta-class, descriptors<br>
|
|
that are of class <a href="google.appengine.ext.db.html#Model">Model</a> are notified about which class they<br>
|
|
belong to and what attribute they are associated with and can<br>
|
|
do appropriate initialization via __property_config__.<br>
|
|
<br>
|
|
Duplicate properties are not permitted.</tt></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="CredentialsProperty">class <strong>CredentialsProperty</strong></a>(<a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>App Engine datastore <a href="google.appengine.ext.db.html#Property">Property</a> for Credentials.<br>
|
|
<br>
|
|
Utility property that allows easy storage and retrieval of<br>
|
|
oath2client.Credentials<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="oauth2client.appengine.html#CredentialsProperty">CredentialsProperty</a></dd>
|
|
<dd><a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a></dd>
|
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="CredentialsProperty-empty"><strong>empty</strong></a>(self, value)</dt></dl>
|
|
|
|
<dl><dt><a name="CredentialsProperty-get_value_for_datastore"><strong>get_value_for_datastore</strong></a>(self, model_instance)</dt><dd><tt># For writing to datastore.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsProperty-make_value_from_datastore"><strong>make_value_from_datastore</strong></a>(self, value)</dt><dd><tt># For reading from datastore.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsProperty-validate"><strong>validate</strong></a>(self, value)</dt></dl>
|
|
|
|
<hr>
|
|
Data and other attributes defined here:<br>
|
|
<dl><dt><strong>data_type</strong> = <class 'oauth2client.client.Credentials'><dd><tt>Base class for all Credentials objects.<br>
|
|
<br>
|
|
Subclasses must define an authorize() method that applies the credentials to<br>
|
|
an HTTP transport.<br>
|
|
<br>
|
|
Subclasses must also specify a classmethod named 'from_json' that takes a JSON<br>
|
|
string as input and returns an instaniated Crentials <a href="__builtin__.html#object">object</a>.</tt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>:<br>
|
|
<dl><dt><a name="CredentialsProperty-__get__"><strong>__get__</strong></a>(self, model_instance, model_class)</dt><dd><tt>Returns the value for this property on the given model instance.<br>
|
|
<br>
|
|
See <a href="http://docs.python.org/ref/descriptors.html">http://docs.python.org/ref/descriptors.html</a> for a description of<br>
|
|
the arguments to this class and what they mean.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsProperty-__init__"><strong>__init__</strong></a>(self, verbose_name<font color="#909090">=None</font>, name<font color="#909090">=None</font>, default<font color="#909090">=None</font>, required<font color="#909090">=False</font>, validator<font color="#909090">=None</font>, choices<font color="#909090">=None</font>, indexed<font color="#909090">=True</font>)</dt><dd><tt>Initializes this <a href="google.appengine.ext.db.html#Property">Property</a> with the given options.<br>
|
|
<br>
|
|
Args:<br>
|
|
verbose_name: User friendly name of property.<br>
|
|
name: <a href="oauth2client.client.html#Storage">Storage</a> name for property. By default, uses attribute name<br>
|
|
as it is assigned in the <a href="google.appengine.ext.db.html#Model">Model</a> sub-class.<br>
|
|
default: Default value for property if none is assigned.<br>
|
|
required: Whether property is required.<br>
|
|
validator: User provided method used for validation.<br>
|
|
choices: User provided set of valid property values.<br>
|
|
indexed: Whether property is indexed.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsProperty-__property_config__"><strong>__property_config__</strong></a>(self, model_class, property_name)</dt><dd><tt>Configure property, connecting it to its model.<br>
|
|
<br>
|
|
Configure the property so that it knows its property name and what class<br>
|
|
it belongs to.<br>
|
|
<br>
|
|
Args:<br>
|
|
model_class: <a href="google.appengine.ext.db.html#Model">Model</a> class which <a href="google.appengine.ext.db.html#Property">Property</a> will belong to.<br>
|
|
property_name: Name of property within <a href="google.appengine.ext.db.html#Model">Model</a> instance to store property<br>
|
|
values in. By default this will be the property name preceded by<br>
|
|
an underscore, but may change for different subclasses.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsProperty-__set__"><strong>__set__</strong></a>(self, model_instance, value)</dt><dd><tt>Sets the value for this property on the given model instance.<br>
|
|
<br>
|
|
See <a href="http://docs.python.org/ref/descriptors.html">http://docs.python.org/ref/descriptors.html</a> for a description of<br>
|
|
the arguments to this class and what they mean.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsProperty-datastore_type"><strong>datastore_type</strong></a>(self)</dt><dd><tt>Deprecated backwards-compatible accessor method for self.<strong>data_type</strong>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="CredentialsProperty-default_value"><strong>default_value</strong></a>(self)</dt><dd><tt>Default value for unassigned values.<br>
|
|
<br>
|
|
Returns:<br>
|
|
Default value as provided by <a href="#CredentialsProperty-__init__">__init__</a>(default).</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
<hr>
|
|
Data and other attributes inherited from <a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>:<br>
|
|
<dl><dt><strong>creation_counter</strong> = 1</dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="FlowProperty">class <strong>FlowProperty</strong></a>(<a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>App Engine datastore <a href="google.appengine.ext.db.html#Property">Property</a> for Flow.<br>
|
|
<br>
|
|
Utility property that allows easy storage and retreival of an<br>
|
|
oauth2client.Flow<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="oauth2client.appengine.html#FlowProperty">FlowProperty</a></dd>
|
|
<dd><a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a></dd>
|
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="FlowProperty-empty"><strong>empty</strong></a>(self, value)</dt></dl>
|
|
|
|
<dl><dt><a name="FlowProperty-get_value_for_datastore"><strong>get_value_for_datastore</strong></a>(self, model_instance)</dt><dd><tt># For writing to datastore.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FlowProperty-make_value_from_datastore"><strong>make_value_from_datastore</strong></a>(self, value)</dt><dd><tt># For reading from datastore.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FlowProperty-validate"><strong>validate</strong></a>(self, value)</dt></dl>
|
|
|
|
<hr>
|
|
Data and other attributes defined here:<br>
|
|
<dl><dt><strong>data_type</strong> = <class 'oauth2client.client.Flow'><dd><tt>Base class for all Flow objects.</tt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>:<br>
|
|
<dl><dt><a name="FlowProperty-__get__"><strong>__get__</strong></a>(self, model_instance, model_class)</dt><dd><tt>Returns the value for this property on the given model instance.<br>
|
|
<br>
|
|
See <a href="http://docs.python.org/ref/descriptors.html">http://docs.python.org/ref/descriptors.html</a> for a description of<br>
|
|
the arguments to this class and what they mean.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FlowProperty-__init__"><strong>__init__</strong></a>(self, verbose_name<font color="#909090">=None</font>, name<font color="#909090">=None</font>, default<font color="#909090">=None</font>, required<font color="#909090">=False</font>, validator<font color="#909090">=None</font>, choices<font color="#909090">=None</font>, indexed<font color="#909090">=True</font>)</dt><dd><tt>Initializes this <a href="google.appengine.ext.db.html#Property">Property</a> with the given options.<br>
|
|
<br>
|
|
Args:<br>
|
|
verbose_name: User friendly name of property.<br>
|
|
name: <a href="oauth2client.client.html#Storage">Storage</a> name for property. By default, uses attribute name<br>
|
|
as it is assigned in the <a href="google.appengine.ext.db.html#Model">Model</a> sub-class.<br>
|
|
default: Default value for property if none is assigned.<br>
|
|
required: Whether property is required.<br>
|
|
validator: User provided method used for validation.<br>
|
|
choices: User provided set of valid property values.<br>
|
|
indexed: Whether property is indexed.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FlowProperty-__property_config__"><strong>__property_config__</strong></a>(self, model_class, property_name)</dt><dd><tt>Configure property, connecting it to its model.<br>
|
|
<br>
|
|
Configure the property so that it knows its property name and what class<br>
|
|
it belongs to.<br>
|
|
<br>
|
|
Args:<br>
|
|
model_class: <a href="google.appengine.ext.db.html#Model">Model</a> class which <a href="google.appengine.ext.db.html#Property">Property</a> will belong to.<br>
|
|
property_name: Name of property within <a href="google.appengine.ext.db.html#Model">Model</a> instance to store property<br>
|
|
values in. By default this will be the property name preceded by<br>
|
|
an underscore, but may change for different subclasses.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FlowProperty-__set__"><strong>__set__</strong></a>(self, model_instance, value)</dt><dd><tt>Sets the value for this property on the given model instance.<br>
|
|
<br>
|
|
See <a href="http://docs.python.org/ref/descriptors.html">http://docs.python.org/ref/descriptors.html</a> for a description of<br>
|
|
the arguments to this class and what they mean.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FlowProperty-datastore_type"><strong>datastore_type</strong></a>(self)</dt><dd><tt>Deprecated backwards-compatible accessor method for self.<strong>data_type</strong>.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="FlowProperty-default_value"><strong>default_value</strong></a>(self)</dt><dd><tt>Default value for unassigned values.<br>
|
|
<br>
|
|
Returns:<br>
|
|
Default value as provided by <a href="#FlowProperty-__init__">__init__</a>(default).</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
<hr>
|
|
Data and other attributes inherited from <a href="google.appengine.ext.db.html#Property">google.appengine.ext.db.Property</a>:<br>
|
|
<dl><dt><strong>creation_counter</strong> = 1</dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="OAuth2Decorator">class <strong>OAuth2Decorator</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Utility for making OAuth 2.0 easier.<br>
|
|
<br>
|
|
Instantiate and then use with oauth_required or oauth_aware<br>
|
|
as decorators on webapp.<a href="google.appengine.ext.webapp.html#RequestHandler">RequestHandler</a> methods.<br>
|
|
<br>
|
|
Example:<br>
|
|
<br>
|
|
decorator = <a href="#OAuth2Decorator">OAuth2Decorator</a>(<br>
|
|
client_id='837...ent.com',<br>
|
|
client_secret='Qh...wwI',<br>
|
|
scope='https://www.googleapis.com/auth/buzz')<br>
|
|
<br>
|
|
<br>
|
|
class MainHandler(webapp.<a href="google.appengine.ext.webapp.html#RequestHandler">RequestHandler</a>):<br>
|
|
<br>
|
|
@decorator.oauth_required<br>
|
|
def get(self):<br>
|
|
http = decorator.<a href="#OAuth2Decorator-http">http</a>()<br>
|
|
# http is authorized with the user's Credentials and can be used<br>
|
|
# in API calls<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="OAuth2Decorator-__init__"><strong>__init__</strong></a>(self, client_id, client_secret, scope, auth_uri<font color="#909090">='https://accounts.google.com/o/oauth2/auth'</font>, token_uri<font color="#909090">='https://accounts.google.com/o/oauth2/token'</font>)</dt><dd><tt>Constructor for <a href="#OAuth2Decorator">OAuth2Decorator</a><br>
|
|
<br>
|
|
Args:<br>
|
|
client_id: string, client identifier.<br>
|
|
client_secret: string client secret.<br>
|
|
scope: string, scope of the credentials being requested.<br>
|
|
auth_uri: string, URI for authorization endpoint. For convenience<br>
|
|
defaults to Google's endpoints but any OAuth 2.0 provider can be used.<br>
|
|
token_uri: string, URI for token endpoint. For convenience<br>
|
|
defaults to Google's endpoints but any OAuth 2.0 provider can be used.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Decorator-authorize_url"><strong>authorize_url</strong></a>(self)</dt><dd><tt>Returns the URL to start the OAuth dance.<br>
|
|
<br>
|
|
Must only be called from with a webapp.<a href="google.appengine.ext.webapp.html#RequestHandler">RequestHandler</a> subclassed method<br>
|
|
that had been decorated with either @oauth_required or @oauth_aware.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Decorator-has_credentials"><strong>has_credentials</strong></a>(self)</dt><dd><tt>True if for the logged in user there are valid access Credentials.<br>
|
|
<br>
|
|
Must only be called from with a webapp.<a href="google.appengine.ext.webapp.html#RequestHandler">RequestHandler</a> subclassed method<br>
|
|
that had been decorated with either @oauth_required or @oauth_aware.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Decorator-http"><strong>http</strong></a>(self)</dt><dd><tt>Returns an authorized http instance.<br>
|
|
<br>
|
|
Must only be called from within an @oauth_required decorated method, or<br>
|
|
from within an @oauth_aware decorated method where <a href="#OAuth2Decorator-has_credentials">has_credentials</a>()<br>
|
|
returns True.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Decorator-oauth_aware"><strong>oauth_aware</strong></a>(self, method)</dt><dd><tt>Decorator that sets up for OAuth 2.0 dance, but doesn't do it.<br>
|
|
<br>
|
|
Does all the setup for the OAuth dance, but doesn't initiate it.<br>
|
|
This decorator is useful if you want to create a page that knows<br>
|
|
whether or not the user has granted access to this application.<br>
|
|
From within a method decorated with @oauth_aware the <a href="#OAuth2Decorator-has_credentials">has_credentials</a>()<br>
|
|
and <a href="#OAuth2Decorator-authorize_url">authorize_url</a>() methods can be called.<br>
|
|
<br>
|
|
Args:<br>
|
|
method: callable, to be decorated method of a webapp.<a href="google.appengine.ext.webapp.html#RequestHandler">RequestHandler</a><br>
|
|
instance.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Decorator-oauth_required"><strong>oauth_required</strong></a>(self, method)</dt><dd><tt>Decorator that starts the OAuth 2.0 dance.<br>
|
|
<br>
|
|
Starts the OAuth dance for the logged in user if they haven't already<br>
|
|
granted access for this application.<br>
|
|
<br>
|
|
Args:<br>
|
|
method: callable, to be decorated method of a webapp.<a href="google.appengine.ext.webapp.html#RequestHandler">RequestHandler</a><br>
|
|
instance.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="OAuth2Handler">class <strong>OAuth2Handler</strong></a>(<a href="google.appengine.ext.webapp.html#RequestHandler">google.appengine.ext.webapp.RequestHandler</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Handler for the redirect_uri of the OAuth 2.0 dance.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="oauth2client.appengine.html#OAuth2Handler">OAuth2Handler</a></dd>
|
|
<dd><a href="google.appengine.ext.webapp.html#RequestHandler">google.appengine.ext.webapp.RequestHandler</a></dd>
|
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="OAuth2Handler-get"><strong>get</strong></a> = check_login(self, *args)</dt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="google.appengine.ext.webapp.html#RequestHandler">google.appengine.ext.webapp.RequestHandler</a>:<br>
|
|
<dl><dt><a name="OAuth2Handler-delete"><strong>delete</strong></a>(self, *args)</dt><dd><tt>Handler method for DELETE requests.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-error"><strong>error</strong></a>(self, code)</dt><dd><tt>Clears the response output stream and sets the given HTTP error code.<br>
|
|
<br>
|
|
Args:<br>
|
|
code: the HTTP status error code (e.g., 501)</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-handle_exception"><strong>handle_exception</strong></a>(self, exception, debug_mode)</dt><dd><tt>Called if this handler throws an exception during execution.<br>
|
|
<br>
|
|
The default behavior is to call <a href="#OAuth2Handler-error">error</a>(500) and print a stack trace<br>
|
|
if debug_mode is True.<br>
|
|
<br>
|
|
Args:<br>
|
|
exception: the exception that was thrown<br>
|
|
debug_mode: True if the web application is running in debug mode</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-head"><strong>head</strong></a>(self, *args)</dt><dd><tt>Handler method for HEAD requests.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-initialize"><strong>initialize</strong></a>(self, request, response)</dt><dd><tt>Initializes this request handler with the given Request and Response.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-options"><strong>options</strong></a>(self, *args)</dt><dd><tt>Handler method for OPTIONS requests.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-post"><strong>post</strong></a>(self, *args)</dt><dd><tt>Handler method for POST requests.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-put"><strong>put</strong></a>(self, *args)</dt><dd><tt>Handler method for PUT requests.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-redirect"><strong>redirect</strong></a>(self, uri, permanent<font color="#909090">=False</font>)</dt><dd><tt>Issues an HTTP redirect to the given relative URL.<br>
|
|
<br>
|
|
Args:<br>
|
|
uri: a relative or absolute URI (e.g., '../flowers.html')<br>
|
|
permanent: if true, we use a 301 redirect instead of a 302 redirect</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-trace"><strong>trace</strong></a>(self, *args)</dt><dd><tt>Handler method for TRACE requests.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Class methods inherited from <a href="google.appengine.ext.webapp.html#RequestHandler">google.appengine.ext.webapp.RequestHandler</a>:<br>
|
|
<dl><dt><a name="OAuth2Handler-get_url"><strong>get_url</strong></a>(cls, *args, **kargs)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Returns the url for the given handler.<br>
|
|
<br>
|
|
The default implementation uses the patterns passed to the active<br>
|
|
WSGIApplication to create a url. However, it is different from Django's<br>
|
|
urlresolvers.reverse() in the following ways:<br>
|
|
- It does not try to resolve handlers via module loading<br>
|
|
- It does not support named arguments<br>
|
|
- It performs some post-prosessing on the url to remove some regex<br>
|
|
operators.<br>
|
|
- It will try to fill in the left-most missing arguments with the args<br>
|
|
used in the active request.<br>
|
|
<br>
|
|
Args:<br>
|
|
args: Parameters for the url pattern's groups.<br>
|
|
kwargs: Optionally contains 'implicit_args' that can either be a boolean<br>
|
|
or a tuple. When it is True, it will use the arguments to the<br>
|
|
active request as implicit arguments. When it is False (default),<br>
|
|
it will not use any implicit arguments. When it is a tuple, it<br>
|
|
will use the tuple as the implicit arguments.<br>
|
|
the left-most args if some are missing from args.<br>
|
|
<br>
|
|
Returns:<br>
|
|
The url for this handler/args combination.<br>
|
|
<br>
|
|
Raises:<br>
|
|
NoUrlFoundError: No url pattern for this handler has the same<br>
|
|
number of args that were passed in.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="OAuth2Handler-new_factory"><strong>new_factory</strong></a>(cls, *args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Create new request handler factory.<br>
|
|
<br>
|
|
Use factory method to create reusable request handlers that just<br>
|
|
require a few configuration parameters to construct. Also useful<br>
|
|
for injecting shared state between multiple request handler<br>
|
|
instances without relying on global variables. For example, to<br>
|
|
create a set of post handlers that will do simple text transformations<br>
|
|
you can write:<br>
|
|
<br>
|
|
class ChangeTextHandler(webapp.<a href="google.appengine.ext.webapp.html#RequestHandler">RequestHandler</a>):<br>
|
|
<br>
|
|
def <a href="#OAuth2Handler-__init__">__init__</a>(self, transform):<br>
|
|
self.<strong>transform</strong> = transform<br>
|
|
<br>
|
|
def <a href="#OAuth2Handler-post">post</a>(self):<br>
|
|
response_text = transform(<br>
|
|
self.<strong>request</strong>.request.body_file.getvalue())<br>
|
|
self.<strong>response</strong>.out.write(response_text)<br>
|
|
<br>
|
|
application = webapp.WSGIApplication(<br>
|
|
[('/to_lower', ChangeTextHandler.<a href="#OAuth2Handler-new_factory">new_factory</a>(str.lower)),<br>
|
|
('/to_upper', ChangeTextHandler.<a href="#OAuth2Handler-new_factory">new_factory</a>(str.upper)),<br>
|
|
],<br>
|
|
debug=True)<br>
|
|
<br>
|
|
Text POSTed to /to_lower will be lower cased.<br>
|
|
Text POSTed to /to_upper will be upper cased.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="google.appengine.ext.webapp.html#RequestHandler">google.appengine.ext.webapp.RequestHandler</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="StorageByKeyName">class <strong>StorageByKeyName</strong></a>(<a href="oauth2client.client.html#Storage">oauth2client.client.Storage</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Store and retrieve a single credential to and from<br>
|
|
the App Engine datastore.<br>
|
|
<br>
|
|
This <a href="oauth2client.client.html#Storage">Storage</a> helper presumes the Credentials<br>
|
|
have been stored as a CredenialsProperty<br>
|
|
on a datastore model class, and that entities<br>
|
|
are stored by key_name.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="oauth2client.appengine.html#StorageByKeyName">StorageByKeyName</a></dd>
|
|
<dd><a href="oauth2client.client.html#Storage">oauth2client.client.Storage</a></dd>
|
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="StorageByKeyName-__init__"><strong>__init__</strong></a>(self, model, key_name, property_name, cache<font color="#909090">=None</font>)</dt><dd><tt>Constructor for <a href="oauth2client.client.html#Storage">Storage</a>.<br>
|
|
<br>
|
|
Args:<br>
|
|
model: db.<a href="google.appengine.ext.db.html#Model">Model</a>, model class<br>
|
|
key_name: string, key name for the entity that has the credentials<br>
|
|
property_name: string, name of the property that is a <a href="#CredentialsProperty">CredentialsProperty</a><br>
|
|
cache: memcache, a write-through cache to put in front of the datastore</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StorageByKeyName-get"><strong>get</strong></a>(self)</dt><dd><tt>Retrieve Credential from datastore.<br>
|
|
<br>
|
|
Returns:<br>
|
|
oauth2client.Credentials</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StorageByKeyName-put"><strong>put</strong></a>(self, credentials)</dt><dd><tt>Write a Credentials to the datastore.<br>
|
|
<br>
|
|
Args:<br>
|
|
credentials: Credentials, the credentials to store.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="oauth2client.client.html#Storage">oauth2client.client.Storage</a>:<br>
|
|
<dl><dt><a name="StorageByKeyName-acquire_lock"><strong>acquire_lock</strong></a>(self)</dt><dd><tt>Acquires any lock necessary to access this <a href="oauth2client.client.html#Storage">Storage</a>.<br>
|
|
<br>
|
|
This lock is not reentrant.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StorageByKeyName-locked_get"><strong>locked_get</strong></a>(self)</dt><dd><tt>Retrieve credential.<br>
|
|
<br>
|
|
The <a href="oauth2client.client.html#Storage">Storage</a> lock must be held when this is called.<br>
|
|
<br>
|
|
Returns:<br>
|
|
oauth2client.client.Credentials</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StorageByKeyName-locked_put"><strong>locked_put</strong></a>(self, credentials)</dt><dd><tt>Write a credential.<br>
|
|
<br>
|
|
The <a href="oauth2client.client.html#Storage">Storage</a> lock must be held when this is called.<br>
|
|
<br>
|
|
Args:<br>
|
|
credentials: Credentials, the credentials to store.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="StorageByKeyName-release_lock"><strong>release_lock</strong></a>(self)</dt><dd><tt>Release the <a href="oauth2client.client.html#Storage">Storage</a> lock.<br>
|
|
<br>
|
|
Trying to release a lock that isn't held will result in a<br>
|
|
RuntimeError.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="oauth2client.client.html#Storage">oauth2client.client.Storage</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#eeaa77">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl><dt><a name="-main"><strong>main</strong></a>()</dt></dl>
|
|
</td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#55aa55">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
|
<td width="100%"><strong>OAUTH2CLIENT_NAMESPACE</strong> = 'oauth2client#ns'<br>
|
|
<strong>__author__</strong> = 'jcgregorio@google.com (Joe Gregorio)'<br>
|
|
<strong>application</strong> = <google.appengine.ext.webapp.WSGIApplication object></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#7799ee">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
|
|
<td width="100%">jcgregorio@google.com (Joe Gregorio)</td></tr></table>
|
|
</body></html> |