id-python / members

Python Indonesia community maps
http://members.python.or.id
GNU General Public License v2.0
9 stars 7 forks source link

Simplified config take 2 #14

Closed iromli closed 10 years ago

iromli commented 10 years ago

This changeset introduces flask-appconfig integration to manage app configuration loading. By using this extension, we have more possibilities to configure the app:

  1. Use default config users/default_config.py.
  2. Use default config and override necessary values using user-defined config file.

    Default config:

    # users/default_config.py
    MAIL_SUPPRESS_SEND=False
    DEBUG = False

    Custom config:

    # /path/to/custom_config.py
    MAIL_SUPPRESS_SEND=True
    DEBUG = True

    Example usage:

    USERS_CONFIG=/path/to/custom_config.py python runserver.py
  3. Use default config and override necessary values using environment variable.

    Default config:

    # users/default_config.py
    MAIL_SUPPRESS_SEND=False
    DEBUG = False

    By using enviroment variable, we could override specific item, for example:

    USERS_MAIL_SUPPRESS_SEND=True USERS_DEBUG=True ./runtests.sh

    Note, to use the environment variable properly, the USERS_ prefix must exist.

Now we have more controls on how to configure app in various usecases, e.g. Travis CI integration.

akbargumbira commented 10 years ago

Thanks @iromli, this is very nice..