{ "info": { "author": "Wampeter Foma", "author_email": "foma@wampeter.org", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Flask-INIConfig\n===============\n\n.. contents:: Table of contents\n\n\nOverview\n--------\n\n`Flask-INIConfig`_ is a `Flask`_ extension that adds two additional methods ``from_inifile`` and ``from_inifile_sections`` to the ``Flask.config`` configuration instance for an application. This allows you to load ini files or sections from an ini file directly into the config object.\n\n\nInstallation\n------------\n\nInstall the extension using ``pip``:\n\n.. code:: bash\n\n $ pip install flask-iniconfig\n\nor ``easy_install``:\n\n.. code:: bash\n\n $ easy_install flask-iniconfig\n\n\nUsage\n-----\n\nBasic Usage\n+++++++++++\n\nYou can initialize the extension by calling it's constructor:\n\n.. code:: python\n\n from flask import Flask\n from flask.ext.iniconfig import INIConfig\n\n app = Flask(__name__)\n INIConfig(app)\n # or use the init_app form\n # INIConfig().init_app(app)\n\n app.config.from_inifile('/path/to/file.ini')\n\n property = (app.config.get('section') or {}).get('property')\n\n.. important::\n\n * Property and section names are **case-sensitive**.\n * Typically ConfigParser normalizes settings and property names to be lower case, however that is turned off for the instance that is used by the extension.\n\n\n``from_inifile``\n++++++++++++++++\n\nWhen you use ``from_inifile`` sections in an ini file are individual properties in the config object. For example if you have the following:\n\n.. code:: ini\n\n [section]\n a_property = 1\n\nand you load it using:\n\n.. code:: python\n\n app.config.from_inifile('/path/to/file.ini')\n\nyou can access it as:\n\n.. code:: python\n\n section = current_app.config.get('section')\n property = section['a_property']\n\n\nAs of ``v0.0.8`` if you provide a flag called ``objectify`` to ``from_inifile``, it will add the section as an instance variable to the config object. You can then load it using:\n\n.. code:: python\n\n app.config.from_inifile('/path/to/file.ini', objectify=True)\n\nwhich will allow you to access it as:\n\n.. code:: python\n\n section = current_app.config.section\n property = section['a_property']\n\n.. important::\n\n * Be **very careful** about the section names so that there is no conflict with built in members as ``app.config`` is merely a dict.\n * These section instance variables are plain dictionaries. Thes are *not* objects themselves.\n\nThere is a special section for `Flask`_ apps called ``flask`` which can be used to specify the application properties. So if you have the following:\n\n.. code:: ini\n\n [flask]\n DEBUG = 1\n\nyou can use ``current_app.config['DEBUG']`` instead of having to specify the section. All property names in the flask section are converted to upper case just like in `from_inifile_sections`_ but only for the flask section.\n\n\n``from_inifile_sections``\n+++++++++++++++++++++++++\n\nWhen you use ``from_inifile_sections`` only the relevant sections and the ``flask`` section, if present, are loaded from the ini file. The other major difference is that instead of ``app.config`` having a property with the name of the section, all properties are tacked on to the ``app.config`` object.\n\nMoreover **all property names are converted to upper-case** as most extensions and Flask's internal `configuration properties `_ are all in upper case.\n\nThe only **exception** is when you provide the ``preserve_case`` flag to this method. When given this will preserve the case for all *non-flask* options. Flask options will still be converted to upper case. This allows you to use things like `sqlalchemy `_'s `engine_from_config `_ directly with the config object.\n\nThis is quite useful if you have one ini file with settings for development, staging, production and test settings you can load only the ones you want which can then be used by flask directly.\n\nFor e.g. if you have the following:\n\n.. code:: ini\n\n [flask]\n DEBUG = 1\n\n [common]\n a = 1\n b = 0\n\n [dev]\n b = 2\n\n [prod]\n b = 3\n\nand you load it using:\n\n.. code:: python\n\n app.config.from_inifile_sections('/path/to/file.ini', ['common', 'dev'])\n\nwhich would add the properties ``A`` and ``B`` to ``app.config``.\n\n.. note::\n This particular method does **not load sections that are not specified**. Prior to `r4372a8e `_ this was not the case and would occasionally cause problems with interpolations.\n\nCustomizing SafeConfigParser\n++++++++++++++++++++++++++++\n\nIf you want to customize the way the internal `SafeConfigParser`_ works you can use the arguments as specified in the `RawConfigParser`_ constructor documentation.\n\nFor example:\n\n.. code:: python\n\n INIConfig(app, defaults={...}, dict_type=OrderedDict, allow_no_value=True)\n\n\nImplementation Details\n----------------------\n\nThe base class that implements the extension is derived from `SafeConfigParser`_ and uses that to load the ini file. Consequently you get the built-in parsing and interpolation capabilities of the parser.\n\nBecause ``SafeConfigParser`` does not automatically coerce the values to an appropriate type, `Flask-INIConfig`_ will try to do it's best to do some for you. The following cast attempts are made in order of precedence:\n\n * `int`_\n * `float`_\n * `boolean`_\n * list, dict or tuple (using `ast.literal_eval `_)\n\n.. note::\n * You do not get access to the parser instance directly, however the constructor will accept the arguments to ``SafeConfigParser`` and pass them through.\n * The extension deviates from ``SafeConfigParser``'s treatment of boolean because a type-coercion to `int`_ happens before a type-coercion to `boolean`_. So if you want a boolean set it to one of ``yes, no, on, off, true or false`` only.\n\n.. warning:: The extension does not try coerce values to types for keys that are already specified in the application configuration. So if you are overriding configuration properties in an ini file you need to be careful about the actual types.\n\n\n.. _Flask-INIConfig: http://bitbucket.org/wampeter/flask-iniconfig\n.. _Flask: http://flask.pocoo.org/\n.. _ConfigParser: https://docs.python.org/2/library/configparser.html\n.. _SafeConfigParser: https://docs.python.org/2/library/configparser.html#safeconfigparser-objects\n.. _int: https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.getint>\n.. _float: https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.getfloat>\n.. _boolean: https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.getboolean\n.. _RawConfigParser: https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/wampeter/flask-iniconfig/", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "Flask-INIConfig", "package_url": "https://pypi.org/project/Flask-INIConfig/", "platform": "any", "project_url": "https://pypi.org/project/Flask-INIConfig/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/wampeter/flask-iniconfig/" }, "release_url": "https://pypi.org/project/Flask-INIConfig/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "A flask extension to load ini files via config", "version": "0.1.0" }, "last_serial": 2209188, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "069c7f96886b36d03650631ee7b12683", "sha256": "4f8f33ff07a3745e3db105c35319f50a7d915b7f9db7bfe000d573dce3513205" }, "downloads": -1, "filename": "Flask-INIConfig-0.0.2.tar.gz", "has_sig": false, "md5_digest": "069c7f96886b36d03650631ee7b12683", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6431, "upload_time": "2014-06-07T04:54:46", "url": "https://files.pythonhosted.org/packages/cf/69/1884e139af15917f0d16146dcce49ef44721e7e66367dbe4df9ca9d804f1/Flask-INIConfig-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "091a050ffac97194384954295b3ee925", "sha256": "4e66d621def5250ff3ac87d442f0798e0b7f75beca97803274233fa839ca8244" }, "downloads": -1, "filename": "Flask-INIConfig-0.0.3.tar.gz", "has_sig": false, "md5_digest": "091a050ffac97194384954295b3ee925", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8659, "upload_time": "2014-06-10T06:19:12", "url": "https://files.pythonhosted.org/packages/55/d8/95c9ca25bbb0ce8a090ebd3651691adb3be7c55499c0e96639f2ad433177/Flask-INIConfig-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "265f8083d3f07d805d6317762f69ece7", "sha256": "c1478eb44fe952ede1e0116f8f9453148329b0ec86ca2cb4ea8bb655f7aa2762" }, "downloads": -1, "filename": "Flask-INIConfig-0.0.4.tar.gz", "has_sig": false, "md5_digest": "265f8083d3f07d805d6317762f69ece7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6919, "upload_time": "2015-08-11T19:12:57", "url": "https://files.pythonhosted.org/packages/94/9e/6581d27aced6bc2de4335c308399e4e1ddb4f0557927e45ba654b5226560/Flask-INIConfig-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "0f4ab9e09179b1625e78c6cb8bf8f427", "sha256": "1e484ac06f8991438b5028f572ad578f708e43fe3bc6b7d44aa0ebecb3438c55" }, "downloads": -1, "filename": "Flask-INIConfig-0.0.5.tar.gz", "has_sig": false, "md5_digest": "0f4ab9e09179b1625e78c6cb8bf8f427", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9089, "upload_time": "2015-09-13T05:12:57", "url": "https://files.pythonhosted.org/packages/08/02/ee628ce63352217ec0ae77589bc209063ef2bb64865471425d2a8a633fab/Flask-INIConfig-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "d9f1c8178a3164974d2b3cd415089acd", "sha256": "213d5cb3c06c9692c604f19cb803f744b75e6e3ce2e74b51ce1e022afb24f9b2" }, "downloads": -1, "filename": "Flask-INIConfig-0.0.6.tar.gz", "has_sig": false, "md5_digest": "d9f1c8178a3164974d2b3cd415089acd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9840, "upload_time": "2015-09-13T07:17:49", "url": "https://files.pythonhosted.org/packages/bb/b4/785e4437cefc8c8a571bd634cdac707a95e2e8d3fea986a6ccc877d0fee9/Flask-INIConfig-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "f5c6a966222f9584d80991e713864a33", "sha256": "64ed4a90e189dfba0eee264d2735b6cb8194f101a6c7154c2f93cc2873bf9468" }, "downloads": -1, "filename": "Flask-INIConfig-0.0.7.tar.gz", "has_sig": false, "md5_digest": "f5c6a966222f9584d80991e713864a33", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9843, "upload_time": "2015-11-05T07:23:55", "url": "https://files.pythonhosted.org/packages/cd/dd/e5ff157f0a0fa643227711af50f1c9b36c67052d03474a6009435b698bb8/Flask-INIConfig-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "afd7532b45f4f774e40d855fbc871dd4", "sha256": "80087d86d521aac598ee4d3020006de58d3e14f5c346547ad27bc6d0b4b3865d" }, "downloads": -1, "filename": "Flask-INIConfig-0.0.8.tar.gz", "has_sig": false, "md5_digest": "afd7532b45f4f774e40d855fbc871dd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10666, "upload_time": "2015-11-05T07:57:55", "url": "https://files.pythonhosted.org/packages/b0/11/ac84c790092619bc729a971d97f88ffeee7eb822e04cc52a17143932253d/Flask-INIConfig-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "44441d5ef3d7879acf0b004873db8920", "sha256": "effcbb4fe8d4a8ffaa3b9f368e782121ce6a9ff88c4fee8036cc3fc21cc69f27" }, "downloads": -1, "filename": "Flask-INIConfig-0.0.9.tar.gz", "has_sig": false, "md5_digest": "44441d5ef3d7879acf0b004873db8920", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10664, "upload_time": "2015-11-05T08:01:14", "url": "https://files.pythonhosted.org/packages/6b/db/cc65bf96288bca07dfd059952459be4c207159ea9fd565ba9e0d0c0e32ed/Flask-INIConfig-0.0.9.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "d2ab4b94ed4a9b475ad10dced9427c97", "sha256": "1fa270b7db8eb8a84449a8556269e78aba35a4b50f96d6ce4ff1a8761c7d944d" }, "downloads": -1, "filename": "Flask_INIConfig-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d2ab4b94ed4a9b475ad10dced9427c97", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8371, "upload_time": "2016-07-08T03:54:55", "url": "https://files.pythonhosted.org/packages/15/a9/1ce9a49c4befbcfee2748cfac9773fea381bf081d68902c3232574f35e68/Flask_INIConfig-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d7fe5e792aee2fcf9d80ef84b2339c73", "sha256": "652d76adf6cb1908e6da2091d2e12b54a8c0fdfd71ff20a3a13a919beeb3d909" }, "downloads": -1, "filename": "Flask-INIConfig-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d7fe5e792aee2fcf9d80ef84b2339c73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11573, "upload_time": "2016-07-08T03:53:12", "url": "https://files.pythonhosted.org/packages/db/4a/998f0ad11b6311d375d7f1c7d2a9dfe394ed8cf10b92ca4816bf10838dc9/Flask-INIConfig-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d2ab4b94ed4a9b475ad10dced9427c97", "sha256": "1fa270b7db8eb8a84449a8556269e78aba35a4b50f96d6ce4ff1a8761c7d944d" }, "downloads": -1, "filename": "Flask_INIConfig-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d2ab4b94ed4a9b475ad10dced9427c97", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 8371, "upload_time": "2016-07-08T03:54:55", "url": "https://files.pythonhosted.org/packages/15/a9/1ce9a49c4befbcfee2748cfac9773fea381bf081d68902c3232574f35e68/Flask_INIConfig-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d7fe5e792aee2fcf9d80ef84b2339c73", "sha256": "652d76adf6cb1908e6da2091d2e12b54a8c0fdfd71ff20a3a13a919beeb3d909" }, "downloads": -1, "filename": "Flask-INIConfig-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d7fe5e792aee2fcf9d80ef84b2339c73", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11573, "upload_time": "2016-07-08T03:53:12", "url": "https://files.pythonhosted.org/packages/db/4a/998f0ad11b6311d375d7f1c7d2a9dfe394ed8cf10b92ca4816bf10838dc9/Flask-INIConfig-0.1.0.tar.gz" } ] }