Metadata Entities Python Reference Stay organized with collections Save and categorize content based on your preferences.
Note:Developers building new applications arestrongly encouraged to use theNDB Client Library, which has several benefitscompared to this client library, such as automatic entity caching via the MemcacheAPI. If you are currently using the older DB Client Library, read theDB to NDB Migration Guide
The model classesEntityGroup,Namespace,Kind, andPropertyrepresent the results of getting or querying metadata kinds.These classes are all defined in the packagegoogle.appengine.ext.db.metadata. See the pageMetadatafor 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 returnNoneif the entity group was never written to.Warning: The behavior of entity group metadata is now different. The entitygroup version can increase independently of user updates. Previously, the entitygroup version increased only on user update. To maintain legacy behavior, use theentity 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 containingentity_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 nameP. - The parent entity's key has kind
__kind__and key nameK. - 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, orNoneif 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
ClassNamespace 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 ID1 instead.)
Property
Instances of classNamespace have the following property:
Class Methods
ClassNamespace has the following class methods:
The Kind Class
ClassKind 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 classKind have the following property:
Class Methods
ClassKind has the following class methods:
The Property Class
ClassProperty represents a metadata entity of the special kind__property__, returned as a result of a property query.The entity representing propertyP of kindK is built as follows:
Properties
Instances of classProperty have the following properties:
Class Methods
ClassProperty has the following class methods:
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.