Python 2.7 has reached end of support and will be deprecated on January 31, 2026. After deprecation, you won't be able to deploy Python 2.7 applications, even if your organization previously used an organization policy to re-enable deployments of legacy runtimes. Your existing Python 2.7 applications will continue to run and receive traffic after their deprecation date. We recommend that you migrate to the latest supported version of Python.

google.appengine.api.capabilities package

Summary

Allows applications to identify API outages and scheduled downtime.

Example:

defStoreUploadedProfileImage(self):
 uploaded_image = self.request.get('img')
 # If the images API is unavailable, we'll just skip the resize.
 if CapabilitySet('images').is_enabled():
 uploaded_image = images.resize(uploaded_image, 64, 64)
 store(uploaded_image)
defRenderHTMLForm(self):
 datastore_readonly = CapabilitySet('datastore_v3', capabilities=['write'])
 if datastore_readonly.is_enabled():
 # ...render form normally...
 else:
 # self.response.out('<p>Not accepting submissions right now: %s</p>' %
 datastore_readonly.admin_message())
 # ...render form with form elements disabled...

Individual API wrapper modules should expose CapabilitySet objects for users rather than relying on users to create them. They can also create convenience methods that delegate to the relevant CapabilitySet; for example, db.IsReadOnly().

Contents

class google.appengine.api.capabilities.CapabilitySet(package, capabilities=None, methods=None, stub_map=google.appengine.api.apiproxy_stub_map)source

Bases: object

Encapsulates one or more capabilities.

Capabilities can either be named explicitly, or inferred from the list of methods provided. If no capabilities or methods are provided, this will check whether the entire package is enabled.

admin_message()source

Retrieves any administrator notice messages for these capabilities.

Returns

A string containing one or more administrator messages, or an empty string.

Raises

UnknownCapabilityError – If a specified capability was not recognized.

is_enabled()source

Tests whether the capabilities are currently enabled.

Returns

True if API calls that require these capabillities will succeed.

Raises

UnknownCapabilityError – If a specified capability was not recognized.

will_remain_enabled_for(time=60)source

Returns whether a capability will remain enabled.

DEPRECATED: this method was never fully implemented and is considered deprecated. Use is_enabled() instead.

Parameters

time – Number of seconds in the future to look when checking for scheduled downtime.

Returns

True if there is no scheduled downtime for the specified capability within the amount of time specified.

Raises

UnknownCapabilityError – If a specified capability was not recognized.

exception google.appengine.api.capabilities.UnknownCapabilityErrorsource

Bases: exceptions.Exception

An unknown capability was requested.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年06月16日 UTC.