Note: Developers building new applications are strongly encouraged to use the NDB Client Library, which has several benefits compared to this client library, such as automatic entity caching via the Memcache API. If you are currently using the older DB Client Library, read the DB to NDB Migration Guide
The model classes
EntityGroup
,
Namespace
,
Kind
,
and
Property
represent the results of getting or querying metadata kinds.
These classes are all defined in the package
google.appengine.ext.db.metadata
. See the page
Metadata
for more information and examples of their use.
Helper Functions
The following helper functions are available for obtaining metadata information without issuing an explicit query or get:
- get_entity_group_version(entity_or_key)
-
Returns the version of the entity group containing
entity_or_key
. This version is guaranteed to increase on every change to the entity group. The version may increase even in the absence of user-visible changes to the entity group. May returnNone
if the entity group was never written to.Warning: The behavior of entity group metadata is now different. The entity group version can increase independently of user updates. Previously, the entity group version increased only on user update. To maintain legacy behavior, use the entity group version workaround.
Arguments:
- entity_or_key
- a key or entity whose version you want.
- get_namespaces(start=None, end=None)
-
Returns a list of namespace names.
Arguments
- start
-
If not
None
, return only namespace names greater than or equal to the specified value. - end
-
If not
None
, return only namespace names less than the specified value.
- get_kinds(start=None, end=None)
-
Returns a list of entity kind names.
Arguments
- start
-
If not
None
, return only kind names greater than or equal to the specified value. - end
-
If not
None
, return only kind names less than the specified value.
- get_properties_of_kind(kind, start=None, end=None)
-
Returns a list of indexed property names for a specified kind. Unindexed properties are not included.
Arguments
- kind
-
The kind whose property names are requested.
- start
-
If not
None
, return only property names greater than or equal to the specified value. - end
-
If not
None
, return only property names less than the specified value.
- get_representations_of_kind(kind, start=None, end=None)
-
Returns a dictionary mapping each indexed property name for a specified kind to a list of its representations. Unindexed properties are not included.
Arguments
- kind
-
The kind whose property representations are requested.
- start
-
If not
None
, return only representations for properties whose names are greater than or equal to the specified value. - end
-
If not
None
, return only representations for properties whose names are less than the specified value.
- version
- The version number
- key_for_entity(entity_or_key)
- Return the metadata key for the entity group containing
entity_or_key
. Use this key as the argument toget()
the__entity_group__
metadata entity for the entity group containing entity_or_key.Arguments:
- entity_or_key
- a key or entity whose
__entity_group__
key you want.
- namespace_name
-
Returns the name of the namespace specified by this entity's key.
- key_for_namespace(namespace)
-
Returns the
__namespace__
key for the specified namespace.Argument
- namespace
-
The namespace whose key is requested.
- key_to_namespace(key)
-
Returns the namespace specified by a given
__namespace__
key.Argument
- key
-
The key whose name is requested.
- kind_name
-
Returns the kind name specified by this entity's key.
- key_for_kind(kind)
-
Returns the
__kind__
key for the specified kind.Argument
- kind
-
The kind whose key is requested.
- key_to_kind(key)
-
Returns the kind specified by a given
__kind__
key.Argument
- key
-
The key whose kind is requested.
- The entity's key has kind
__property__
and key name P. - The parent entity's key has kind
__kind__
and key name K. - kind_name
-
Returns the kind name specified by this entity's key.
- property_name
-
Returns the property name specified by this entity's key.
- key_for_kind(kind)
-
Returns the parent key for
__property__
keys of the specified kind.Argument
- kind
-
The kind whose parent key is requested.
- key_for_property(kind, property)
-
Returns the
__property__
key for the specified property and kind.Arguments
- kind
-
The kind whose key is requested.
- property
-
The property whose key is requested.
- key_to_kind(key)
-
Returns the kind specified by a given
__property__
key.Argument
- key
-
The key whose kind name is requested.
- key_to_property(key)
-
Returns the property specified by a given
__property__
key, orNone
if the key specified only a kind.Argument
- key
-
The key whose property name is requested.
The EntityGroup Class
Model for __entity_group__
metadata
(available in HR datastore only).
This metadata contains a numeric __version__
property that is guaranteed
to increase on every change to the entity group. The version may increase
even in the absence of user-visible changes to the entity group. The
__entity_group__
entity may not exist if the entity
group was never written to.
Property
Class Method
The Namespace Class
Class Namespace
represents a metadata entity of the special kind __namespace__
, returned as a result of a
namespace query.
The entity's key is the name of the namespace. (An exception is the default namespace designated by the empty string ""
: since this is not a valid key name, the default namespace is represented by a key with numeric ID 1
instead.)
Property
Instances of class Namespace
have the following property:
Class Methods
Class Namespace
has the following class methods:
The Kind Class
Class Kind
represents a metadata entity of the special kind __kind__
, returned as a result of a
kind query.
The entity's key is the name of the entity kind.
Property
Instances of class Kind
have the following property:
Class Methods
Class Kind
has the following class methods:
The Property Class
Class Property
represents a metadata entity of the special kind __property__
, returned as a result of a
property query.
The entity representing property P of kind K is built as follows:
Properties
Instances of class Property
have the following properties:
Class Methods
Class Property
has the following class methods: