This module is deprecated. webapp2.WSGIApplication now has a simple configuration dictionary used by default, stored in webapp2.WSGIApplication.config. See also webapp2.Config.
Value used for missing default values.
Value used for required values.
A simple configuration dictionary keyed by module name. This is a dictionary of dictionaries. It requires all values to be dictionaries and applies updates and default values to the inner dictionaries instead of the first level one.
The configuration object can be set as a config attribute of WSGIApplication:
import webapp2
from webapp2_extras import config as webapp2_config
my_config = {}
my_config['my.module'] = {
'foo': 'bar',
}
app = webapp2.WSGIApplication(routes=[
webapp2.Route('/', name='home', handler=MyHandler)
])
app.config = webapp2_config.Config(my_config)
Then to read configuration values, get them from the app:
class MyHandler(RequestHandler):
def get(self):
foo = self.app.config['my.module']['foo']
# ...
Returns the configuration for a module. If it is not already set, loads a default_config variable from the given module and updates the configuration with those default values
Every module that allows some kind of configuration sets a default_config global variable that is loaded by this function, cached and used in case the requested configuration was not defined by the user.
Parameters: | module – The module name. |
---|---|
Returns: | A configuration value. |
Initializes the configuration object.
Parameters: |
|
---|
Sets a configuration for a module, requiring it to be a dictionary.
Parameters: |
|
---|
Returns a configuration for a module. If default is not provided, returns an empty dict if the module is not configured.
Parameters: | module – The module name. |
---|---|
Params default: | Default value to return if the module is not configured. If not set, returns an empty dict. |
Returns: | A module configuration. |
Returns a configuration value for a module and optionally a key. Will raise a KeyError if they the module is not configured or the key doesn’t exist and a default is not provided.
Parameters: |
|
---|---|
Params key: | The configuration key. |
Returns: | A module configuration. |