Metadata-Version: 2.0
Name: Flask-WaffleConf
Version: 0.1.0
Summary: Store certain configuration variables in database
Home-page: https://github.com/rmed/flask-waffleconf
Author: Rafael Medina García
Author-email: rafamedgar@gmail.com.com
License: GPLv2+
Platform: any
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Flask
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: Flask

Flask-WaffleConf |PyPI version|
===============================

A Flask extension that enables storage of configuration variables in the
database as well as runtime modification of these variables.

**Released under GPLv2+ license.**

Installation
============

.. code:: shell

    $ pip install Flask-WaffleConf

Configuration
=============

The extension uses the following configuration variables:

-  ``WAFFLE_CONFS``: Used for specifying the configuration variables
   that are going to be stored in the database. It has the following
   structure:

.. code:: python

    WAFFLE_CONFS = {
        'CONF_VAR1': {
            'type': 'str',
            'desc': 'First config var',
            'default': '0'
        },
        'CONF_VAR2': {
            'type': 'int',
            'desc': 'Second config var',
            'default': '0'
        }
    }

-  ``WAFFLE_TEMPLATE``: Template containing the form used for updating
   the configuration values. You are highly encouraged to extend the
   default template.

Example Application using peewee as ORM
=======================================

.. code:: python

    from flask import Flask
    from flask.ext.waffleconf import WaffleConf, PeeweeWaffleStore, \
        WaffleMixin, register_waffle
    import peewee

    app = Flask(__name__)
    app.config['WAFFLE_CONFS'] = {
        'CONF_VAR1': {
            'type': 'str',
            'desc': 'First config var',
            'default': '0'
        },
        'CONF_VAR2': {
            'type': 'int',
            'desc': 'Second config var',
            'default': '0'
        }
    }

    # Define your database
    # db = ...

    # Define model
    class ConfModel(peewee.model, WaffleMixin):
        class Meta:
            database = db

        key = peewee.CharField(unique=True)
        value = peewee.TextField()

    # Create database tables
    # ...

    # Initialize WaffleConf
    configstore = PeeweeWaffleStore(ConfModel)
    waffle = WaffleConf(app, configstore)

    # Plug the WaffleConf view to any of your Blueprints
    register_waffle(app, 'waffleconf', '/config')

Documentation
=============

Documentation is present in the ``docs/`` directory and also online at
https://flask-waffleconf.readthedocs.org. In order to build the
documentation from source (you will need MkDocs), run:

.. code:: shell

    $ mkdocs build

.. |PyPI version| image:: https://img.shields.io/pypi/v/Flask-WaffleConf.svg
   :target: https://pypi.python.org/pypi/Flask-WaffleConf


