google.appengine.api.capabilities package

Submodules

Module contents

Allows applications to identify API outages and scheduled downtime.

Some examples:
def StoreUploadedProfileImage(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)

def RenderHTMLForm(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 may also create convenience methods (e.g. db.IsReadOnly()) that delegate to the relevant CapabilitySet.

Classes defined here:
CapabilitySet: encapsulates one or more capabilities, allows introspection. UnknownCapabilityError: thrown when an unknown capability is requested.
class google.appengine.api.capabilities.CapabilitySet(package, capabilities=None, methods=None, stub_map=<module 'google.appengine.api.apiproxy_stub_map' from '/tmp/pythonsdk/google_appengine/google/appengine/api/apiproxy_stub_map.py'>)[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]

Get any administrator notice messages for these capabilities.

Returns:
A string containing one or more admin messages, or an empty string.
Raises:
UnknownCapabilityError, if a specified capability was not recognized.
is_enabled()[source]

Tests whether the capabilities is 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 true if it will remain enabled for the specified amount of time.

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

Args:
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.UnknownCapabilityError[source]

Bases: exceptions.Exception

An unknown capability was requested.