1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module gdata.alt.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="gdata.html"><font color="#ffffff">gdata</font></a>.<a href="gdata.alt.html"><font color="#ffffff">alt</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:/home/afshar/wrk/gdata-python-client/src/gdata/alt/appengine.py">/home/afshar/wrk/gdata-python-client/src/gdata/alt/appengine.py</a></font></td></tr></table>
<p><tt>Provides HTTP functions for gdata.service to use on Google App Engine<br>
<br>
<a href="#AppEngineHttpClient">AppEngineHttpClient</a>: Provides an HTTP request method which uses App Engine's<br>
urlfetch API. Set the http_client member of a GDataService <a href="__builtin__.html#object">object</a> to an<br>
instance of an <a href="#AppEngineHttpClient">AppEngineHttpClient</a> to allow the gdata library to run on<br>
Google App Engine.<br>
<br>
run_on_appengine: Function which will modify an existing GDataService <a href="__builtin__.html#object">object</a><br>
to allow it to run on App Engine. It works by creating a new instance of<br>
the <a href="#AppEngineHttpClient">AppEngineHttpClient</a> and replacing the GDataService <a href="__builtin__.html#object">object</a>'s<br>
http_client.</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="StringIO.html">StringIO</a><br>
<a href="atom.html">atom</a><br>
</td><td width="25%" valign=top><a href="google.appengine.ext.db.html">google.appengine.ext.db</a><br>
<a href="google.appengine.api.memcache.html">google.appengine.api.memcache</a><br>
</td><td width="25%" valign=top><a href="pickle.html">pickle</a><br>
<a href="google.appengine.api.urlfetch.html">google.appengine.api.urlfetch</a><br>
</td><td width="25%" valign=top><a href="google.appengine.api.users.html">google.appengine.api.users</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="gdata.alt.appengine.html#HttpResponse">HttpResponse</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gdata.alt.appengine.html#AppEngineHttpClient">AppEngineHttpClient</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="atom.token_store.html#TokenStore">atom.token_store.TokenStore</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gdata.alt.appengine.html#AppEngineTokenStore">AppEngineTokenStore</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="gdata.alt.appengine.html#TokenCollection">TokenCollection</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="AppEngineHttpClient">class <strong>AppEngineHttpClient</strong></a>(<a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="gdata.alt.appengine.html#AppEngineHttpClient">AppEngineHttpClient</a></dd>
<dd><a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="AppEngineHttpClient-__init__"><strong>__init__</strong></a>(self, headers<font color="#909090">=None</font>, deadline<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AppEngineHttpClient-request"><strong>request</strong></a>(self, operation, url, data<font color="#909090">=None</font>, headers<font color="#909090">=None</font>)</dt><dd><tt>Performs an HTTP call to the server, supports GET, POST, PUT, and<br>
DELETE.<br>
<br>
Usage example, perform and HTTP GET on <a href="http://www.google.com/">http://www.google.com/</a>:<br>
import atom.http<br>
client = atom.http.HttpClient()<br>
http_response = client.<a href="#AppEngineHttpClient-request">request</a>('GET', '<a href="http://www.google.com/">http://www.google.com/</a>')<br>
<br>
Args:<br>
operation: str The HTTP operation to be performed. This is usually one<br>
of 'GET', 'POST', 'PUT', or 'DELETE'<br>
data: filestream, list of parts, or other <a href="__builtin__.html#object">object</a> which can be converted<br>
to a string. Should be set to None when performing a GET or DELETE.<br>
If data is a file-like <a href="__builtin__.html#object">object</a> which can be read, this method will<br>
read a chunk of 100K bytes at a time and send them.<br>
If the data is a list of parts to be sent, each part will be<br>
evaluated and sent.<br>
url: The full URL to which the request should be sent. Can be a string<br>
or atom.url.Url.<br>
headers: dict of strings. HTTP headers which should be sent<br>
in the request.</tt></dd></dl>
<hr>
Methods inherited from <a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>:<br>
<dl><dt><a name="AppEngineHttpClient-delete"><strong>delete</strong></a>(self, url, headers<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AppEngineHttpClient-get"><strong>get</strong></a>(self, url, headers<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AppEngineHttpClient-post"><strong>post</strong></a>(self, url, data, headers<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="AppEngineHttpClient-put"><strong>put</strong></a>(self, url, data, headers<font color="#909090">=None</font>)</dt></dl>
<hr>
Data descriptors inherited from <a href="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</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="atom.http_interface.html#GenericHttpClient">atom.http_interface.GenericHttpClient</a>:<br>
<dl><dt><strong>debug</strong> = False</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="AppEngineTokenStore">class <strong>AppEngineTokenStore</strong></a>(<a href="atom.token_store.html#TokenStore">atom.token_store.TokenStore</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Stores the user's auth tokens in the App Engine datastore.<br>
<br>
Tokens are only written to the datastore if a user is signed in (if <br>
users.get_current_user() returns a user <a href="__builtin__.html#object">object</a>).<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="gdata.alt.appengine.html#AppEngineTokenStore">AppEngineTokenStore</a></dd>
<dd><a href="atom.token_store.html#TokenStore">atom.token_store.TokenStore</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="AppEngineTokenStore-__init__"><strong>__init__</strong></a>(self)</dt></dl>
<dl><dt><a name="AppEngineTokenStore-add_token"><strong>add_token</strong></a>(self, token)</dt><dd><tt>Associates the token with the current user and stores it.<br>
<br>
If there is no current user, the token will not be stored.<br>
<br>
Returns:<br>
False if the token was not stored.</tt></dd></dl>
<dl><dt><a name="AppEngineTokenStore-find_token"><strong>find_token</strong></a>(self, url)</dt><dd><tt>Searches the current user's collection of token for a token which can<br>
be used for a request to the url.<br>
<br>
Returns:<br>
The stored token which belongs to the current user and is valid for the<br>
desired URL. If there is no current user, or there is no valid user <br>
token in the datastore, a atom.http_interface.GenericToken is returned.</tt></dd></dl>
<dl><dt><a name="AppEngineTokenStore-remove_all_tokens"><strong>remove_all_tokens</strong></a>(self)</dt><dd><tt>Removes all of the current user's tokens from the datastore.</tt></dd></dl>
<dl><dt><a name="AppEngineTokenStore-remove_token"><strong>remove_token</strong></a>(self, token)</dt><dd><tt>Removes the token from the current user's collection in the datastore.<br>
<br>
Returns:<br>
False if the token was not removed, this could be because the token was<br>
not in the datastore, or because there is no current user.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="atom.token_store.html#TokenStore">atom.token_store.TokenStore</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="HttpResponse">class <strong>HttpResponse</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>Translates a urlfetch resoinse to look like an hhtplib resoinse.<br>
<br>
Used to allow the resoinse from HttpRequest to be usable by gdata.service<br>
methods.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="HttpResponse-__init__"><strong>__init__</strong></a>(self, urlfetch_response)</dt></dl>
<dl><dt><a name="HttpResponse-getheader"><strong>getheader</strong></a>(self, name)</dt></dl>
<dl><dt><a name="HttpResponse-read"><strong>read</strong></a>(self, length<font color="#909090">=None</font>)</dt></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="TokenCollection">class <strong>TokenCollection</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>Datastore <a href="google.appengine.ext.db.html#Model">Model</a> which associates auth tokens with the current user.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="gdata.alt.appengine.html#TokenCollection">TokenCollection</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>pickled_tokens</strong></dt>
<dd><tt>A byte string that can be longer than 500 bytes.</tt></dd>
</dl>
<dl><dt><strong>user</strong></dt>
<dd><tt>A user property.</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="TokenCollection-__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="#TokenCollection-put">put</a>(),<br>
which saves the entity to the datastore:<br>
<br>
person = Person()<br>
person.name = 'Bret'<br>
person.<a href="#TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-instance_properties"><strong>instance_properties</strong></a>(self)</dt><dd><tt>Alias for dyanmic_properties.</tt></dd></dl>
<dl><dt><a name="TokenCollection-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="TokenCollection-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="#TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="#TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="#TokenCollection-get_or_insert">get_or_insert</a>(wiki_word,<br>
body='This topic is totally new!')<br>
assert topic.<a href="#TokenCollection-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="#TokenCollection-get_or_insert">get_or_insert</a>(wiki_word,<br>
body='A totally different message!')<br>
assert topic.<a href="#TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-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="TokenCollection-__new__"><strong>__new__</strong></a>(*args, **unused_kwds)</dt><dd><tt>Allow subclasses to call <a href="#TokenCollection-__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 Property<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></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="-load_auth_tokens"><strong>load_auth_tokens</strong></a>(user<font color="#909090">=None</font>)</dt><dd><tt>Reads a dictionary of the current user's tokens from the datastore.<br>
<br>
If there is no current user (a user is not signed in to the app) or the user<br>
does not have any tokens, an empty dictionary is returned.</tt></dd></dl>
<dl><dt><a name="-run_on_appengine"><strong>run_on_appengine</strong></a>(gdata_service, store_tokens<font color="#909090">=True</font>, single_user_mode<font color="#909090">=False</font>, deadline<font color="#909090">=None</font>)</dt><dd><tt>Modifies a GDataService <a href="__builtin__.html#object">object</a> to allow it to run on App Engine.<br>
<br>
Args:<br>
gdata_service: An instance of AtomService, GDataService, or any<br>
of their subclasses which has an http_client member and a <br>
token_store member.<br>
store_tokens: Boolean, defaults to True. If True, the gdata_service<br>
will attempt to add each token to it's token_store when<br>
SetClientLoginToken or SetAuthSubToken is called. If False<br>
the tokens will not automatically be added to the <br>
token_store.<br>
single_user_mode: Boolean, defaults to False. If True, the current_token<br>
member of gdata_service will be set when <br>
SetClientLoginToken or SetAuthTubToken is called. If set<br>
to True, the current_token is set in the gdata_service<br>
and anyone who accesses the <a href="__builtin__.html#object">object</a> will use the same <br>
token. <br>
<br>
Note: If store_tokens is set to False and <br>
single_user_mode is set to False, all tokens will be <br>
ignored, since the library assumes: the tokens should not<br>
be stored in the datastore and they should not be stored<br>
in the gdata_service <a href="__builtin__.html#object">object</a>. This will make it <br>
impossible to make requests which require authorization.<br>
deadline: int (optional) The number of seconds to wait for a response<br>
before timing out on the HTTP request. If no deadline is<br>
specified, the deafault deadline for HTTP requests from App<br>
Engine is used. The maximum is currently 10 (for 10 seconds).<br>
The default deadline for App Engine is 5 seconds.</tt></dd></dl>
<dl><dt><a name="-save_auth_tokens"><strong>save_auth_tokens</strong></a>(token_dict, user<font color="#909090">=None</font>)</dt><dd><tt>Associates the tokens with the current user and writes to the datastore.<br>
<br>
If there us no current user, the tokens are not written and this function<br>
returns None.<br>
<br>
Returns:<br>
The key of the datastore entity containing the user's tokens, or None if<br>
there was no current user.</tt></dd></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>__author__</strong> = 'api.jscudder (Jeff Scudder)'</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%">api.jscudder (Jeff Scudder)</td></tr></table>
</body></html>
|