Python 2.7 has reached end of supportand will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy Python 2.7applications, even if your organization previously used an organization policy tore-enable deployments of legacy runtimes. Your existing Python2.7 applications will continue to run and receive traffic after theirdeprecation date. We recommend thatyoumigrate to the latest supported version of Python.

Metadata Entities Python Reference

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 containingentity_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 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 notNone, return only namespace names greater than or equal to the specified value.

end

If notNone, 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 notNone, return only kind names greater than or equal to the specified value.

end

If notNone, 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 notNone, return only property names greater than or equal to the specified value.

end

If notNone, 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 notNone, return only representations for properties whose names are greater than or equal to the specified value.

end

If notNone, return only representations for properties whose names are less than the specified value.

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

version
The version number

Class Method

key_for_entity(entity_or_key)
Return the metadata key for the entity group containingentity_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.

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:

namespace_name

Returns the name of the namespace specified by this entity's key.

Class Methods

ClassNamespace has the following class methods:

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.

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:

kind_name

Returns the kind name specified by this entity's key.

Class Methods

ClassKind has the following class methods:

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 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:

  • The entity's key has kind__property__ and key nameP.
  • The parent entity's key has kind__kind__ and key nameK.

Properties

Instances of classProperty have the following properties:

kind_name

Returns the kind name specified by this entity's key.

property_name

Returns the property name specified by this entity's key.

Class Methods

ClassProperty has the following class methods:

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.

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.