Giter Club home page Giter Club logo

pykonfigure's Introduction

##pyKonfigure I like to deploy to PAAS providers like heroku and like an easy way to support getting configuration variables from the application environment. Plus I've been using the same basic code for all my flask applications, supporting different configuration environments by having a POPO per environment (test, development, production, etc). You can have as many environments as you want and what they mean is up to you. A common base class can be used to for settings that are the same in each.

Here's an example settings file:

class Config(object):
    MAIL_PORT = 32


class TestConfig(Config):
    DEBUG = True
    MONGODB_SETTINGS = {
        'DB': 'test'
    }


class ProdConfig(Config):
    """Production configuration."""
    DEBUG = False
    DEBUG_TB_ENABLED = False  # Disable Debug toolbar
    MONGODB_SETTINGS = {
        'DB': 'production'
    }
    MAIL_SUPPRESS_SEND = True


class DevConfig(Config):
    """Development configuration."""
    DEBUG = True
    MONGODB_SETTINGS = {
        'DB': 'development'
    }
    MAIL_SUPPRESS_SEND = True

There are 3 configuration classes and a base class. This is how you create an instance of pyKonfigure:

cfg = Konfigure( mappings={"FLASK_ENV": "ENV"},
     env_keys={'test': 'TestConfig','development': 'DevConfig','production': 'ProdConfig'},
     settings_loc='settings')

those happen to be all the default values. Starting from the end settings_loc is a string identifying the module containing the above configuration fle. env_keys map each environment to a class containing its settings and mappings is a list of

pykonfigure's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.