API capabilities. You can use this API to reduce downtime in your application by detecting when a capability is unavailable and then bypassing it.
For example, if you use the Images API to resize images, you can use the Capabilities API to detect when the Images API is unavailable and skip the resize:
from google.appengine.api import capabilities def StoreUploadedProfileImage(self): uploaded_image = self.request.get('img') # If the images API is unavailable, we'll just skip the resize. if capabilities.CapabilitySet('images').is_enabled(): uploaded_image = images.resize(uploaded_image, 64, 64) store(uploaded_image)
The Datastore API provides a convenience wrapper for the Datastore read and write capabilities. While you can test capabilities simply by supplying the capability name as an argument to
CapabilitySet(), in this case you can also use the
CapabilitySet objects. The following sample shows how to detect the availability of Datastore writes using a convenience wrapper and, during downtime, provide a message to users:
from google.appengine.ext import db def RenderHTMLForm(self): if not db.WRITE_CAPABILITY.is_enabled(): # Datastore is in read-only mode.
Using the Capabilities API in Python
The CapabilitySet class defines all of the available methods for this API. You can either name capabilities explicitly or infer them from the methods provided by this class. See below for the list of services currently enabled in this API.
The API currently supports the following capabilities:
|Availability of the blobstore||
|Availability of the Images service||
|Availability of the Mail service||
|Availability of the Memcache service||
|Availability of the Task Queue service||
|Availability of the URL Fetch service||
|Availability of the XMPP service||