View source on GitHub |
Allows applications to identify API outages and scheduled downtime.
Example:
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 can
also create convenience methods that delegate to the relevant `CapabilitySet`;
for example, `db.IsReadOnly()`.
## Modules
[`capability_stub`](../../../google/appengine/api/capabilities/capability_stub) module: Stub version of the capability service API.
## Classes
[`class CapabilitySet`](../../../google/appengine/api/capabilities/CapabilitySet): Encapsulates one or more capabilities.
[`class UnknownCapabilityError`](../../../google/appengine/api/capabilities/UnknownCapabilityError): An unknown capability was requested.