google.appengine.api.conf module

Summary

A library for managing flags-like configuration that update dynamically.

Contents

class google.appengine.api.conf.Config(parent=None, key_name=None, _app=None, **kwds)source

Bases: google.appengine.ext.db.Expando

The representation of a config in the datastore and memcache.

ah__conf__load_from_yaml(parsed_config)source

Loads all the params from a YAMLConfiguration into expando fields.

We set these expando properties with a special name prefix ‘p_’ to keep them separate from the static attributes of Config. That way we don’t have to check elsewhere to make sure the user doesn’t stomp on our built in properties.

Parameters

parse_config – A YAMLConfiguration.

ah__conf__version

An integer property.

classmethod kind()source

Override the kind name to prevent collisions with users.

google.appengine.api.conf.LoadSingleConf(stream)source

Load a conf.yaml file or string and return a YAMLConfiguration object.

Parameters

stream – a file object corresponding to a conf.yaml file, or its contents as a string.

Returns

A YAMLConfiguration instance

class google.appengine.api.conf.YAMLConfiguration(**attributes)source

Bases: google.appengine.api.validation.Validated

This class describes the structure of a conf.yaml file.

At the top level the file should have a params attribue which is a mapping from strings to scalars. For example:

Parameters
  • background_color – ‘red’

  • message_size – 1024

  • boolean_valued_param – true

ATTRIBUTES = {'parameters': <class 'google.appengine.api.conf._ParameterDict'>}
google.appengine.api.conf.get(name, default=None)source

Get the value of a configuration parameter.

This function is guaranteed to return the same value for every call during a single request.

Parameters
  • name – The name of the configuration parameter you want a value for.

  • default – A default value to return if the named parameter doesn’t exist.

Returns

The string value of the configuration parameter.

google.appengine.api.conf.get_all()source

Return an object with an attribute for each conf parameter.

Returns

An object with an attribute for each conf parameter.

google.appengine.api.conf.refresh()source

Update the local config cache from memcache/datastore.

Normally configuration parameters are only refreshed at the start of a new request. If you have a very long running request, or you just need the freshest data for some reason, you can call this function to force a refresh.