From 74ee615920ced09fcd345632d06e81b7715f2d6c Mon Sep 17 00:00:00 2001 From: Tim Richardson Date: Sun, 6 Sep 2015 14:47:32 +1000 Subject: [PATCH] typo fixes --- sources/29-web2py-english/13.markmin | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/sources/29-web2py-english/13.markmin b/sources/29-web2py-english/13.markmin index 5fa8930a..09658187 100644 --- a/sources/29-web2py-english/13.markmin +++ b/sources/29-web2py-english/13.markmin @@ -1,17 +1,19 @@ ## Deployment: development and production +``appconfig``:inxx +[[appconfig]] +### AppConfig module + The environment between your development and production system will almost certainly mean a different database configuration, different mail servers and possibly other differences. -Web2py uses the private directory for storing information which is not replicated in a typical deployment to productoin. +Web2py intends the private directory for storing information which is not replicated in a typical deployment to production (although you need to take care to make sure that you are not deploying that directory). + The contributed module ``AppConfig`` allows the private directory to store a simple configuration text file to define settings which vary between dev and production, such as database connections. By default it is a text file which is pythonesque, but json is also supported. The welcome app now uses this module in ``db.py`` to read configuration from a file in the application's private directory. By default the path to this file is ``private/app_config.ini`` -Private directories are ignored by git in the default web2py settings, as the private folder is designed to be a safe place to store sensitive information. - -An easy way to learn about this module is to create a new app an inspect the default usage. -By default, app_config.ini allows you to define a database connection and smtp configuration. When the application is stable, the module can be set to cached mode to reduce overhead. +By default, ``app_config.ini`` allows you to define a database connection and smtp configuration. When the application is stable, the module can be set to cached mode to reduce overhead. `` from gluon.contrib.appconfig import AppConfig ... @@ -19,9 +21,20 @@ myconf = AppConfig(reload=False)``:code Applications created in a recent version of web2py default to having the database connection defined with AppConfig. +The values in app_config.ini are fetched and cast from a string value by like so: +`` +myconf = AppConfig() +... +a_config_value = myconf.take('example_section.example_key',cast=int) +``:code + +Because the casting occurs from a string, and non empty strings cast to True, the safest way to represent a Boolean False is with an empty string: +`` +[example_section] +example_key = +``:code ## Deployment recipes: Infrastructure - There are multiple ways to deploy web2py in a production environment. The details depend on the configuration and the services provided by the host. In this chapter we consider the following issues: