The primary key for a datastore entity.
A datastore GUID. A Key instance uniquely identifies an entity across all
apps, and includes all information necessary to fetch the entity from the
datastore with Get().
Key implements __hash__, and key instances are immutable, so Keys may be
used in sets and as dictionary keys.
def google.appengine.api.datastore_types.Key.__cmp__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Returns negative, zero, or positive when comparing two keys.
TODO: for API v2, we should change this to make incomplete keys, ie
keys without an id or name, not equal to any other keys.
Args:
other: Key to compare to.
Returns:
Negative if self is less than "other"
Zero if "other" is equal to self
Positive if self is greater than "other"
def google.appengine.api.datastore_types.Key.__str__ |
( |
|
self | ) |
|
Encodes this Key as an opaque string.
Returns a string representation of this key, suitable for use in HTML,
URLs, and other similar use cases. If the entity's key is incomplete,
raises a BadKeyError.
Unfortunately, this string encoding isn't particularly compact, and its
length varies with the length of the path. If you want a shorter identifier
and you know the kind and parent (if any) ahead of time, consider using just
the entity's id or name.
Returns:
string
def google.appengine.api.datastore_types.Key.from_path |
( |
|
args, |
|
|
|
kwds |
|
) |
| |
|
static |
Static method to construct a Key out of a "path" (kind, id or name, ...).
This is useful when an application wants to use just the id or name portion
of a key in e.g. a URL, where the rest of the URL provides enough context to
fill in the rest, i.e. the app id (always implicit), the entity kind, and
possibly an ancestor key. Since ids and names are usually small, they're
more attractive for use in end-user-visible URLs than the full string
representation of a key.
Args:
kind: the entity kind (a str or unicode instance)
id_or_name: the id (an int or long) or name (a str or unicode instance)
parent: optional parent Key; default None.
namespace: optional namespace to use otherwise namespace_manager's
default namespace is used.
Returns:
A new Key instance whose .kind() and .id() or .name() methods return
the *last* kind and id or name positional arguments passed.
Raises:
BadArgumentError for invalid arguments.
BadKeyError if the parent key is incomplete.
def google.appengine.api.datastore_types.Key.ToTagUri |
( |
|
self | ) |
|
Returns a tag: URI for this entity for use in XML output.
Foreign keys for entities may be represented in XML output as tag URIs.
RFC 4151 describes the tag URI scheme. From http://taguri.org/:
The tag algorithm lets people mint - create - identifiers that no one
else using the same algorithm could ever mint. It is simple enough to do
in your head, and the resulting identifiers can be easy to read, write,
and remember. The identifiers conform to the URI (URL) Syntax.
Tag URIs for entities use the app's auth domain and the date that the URI
is generated. The namespace-specific part is <kind>[<key>].
For example, here is the tag URI for a Kitten with the key "Fluffy" in the
catsinsinks app:
tag:catsinsinks.googleapps.com,2006-08-29:Kitten[Fluffy]
Raises a BadKeyError if this entity's key is incomplete.