This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
===========
confcollect
===========

The idea is for you to do::

app = SomeWsgiAppMaybe(__name__)
app.config.update({
'SOME_SERVICE_URL': 'http://localhost:4931'
})

app.config.update(confcollect.from_module('config'))
app.config.update(confcollect.from_environ(by_defaults=app.config))

The last two lines are everything that is needed to support configuration via
a uppercase-style 'config.py' module and configuration via the environment
(say, to run on Heroku).

When reading from the environment, it automatically converts to the right
type based on the defaults that you have given. If you need more flexiblity,
``from_environ`` supports something called ``specs``.


Using Django
============

You would do something like this in your ``settings.py`` file::

import confcollect, sys
_my = sys.modules[__name__]

_my.__dict__.update(confcollect.from_module('myproject.config', silent=False))
_my.__dict__.update(confcollect.from_environ(by_defaults=_my.__dict__))


Complex settings
================

In Django, some settings are nested dicts. Take for example::


HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
}
}


How do we read this from the environment?

The native way doesn't work, because ``by_defaults`` does only support simple,
but not nested dicts. Meaning while the following works::

set USERS="michael=secret,peter=12345"
>>> confcollect.from_environ(by_defaults={'users': {}})
{'users': {'michael': 'secret', 'peter': 12345}}

There is no way to set ``USERS`` such that we can generate a nested dict.

One way to fix this is by targeting one of the nested dictionaries directly,
using a custom spec::

set SEARCH="ENGINE=elastic,URL=http://127.0.0.1:9200/"
>>> confcollect.from_environ(spec('SEARCH', convert="dict", write_dict='HAYSTACK_CONNECTIONS.default'))
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'elastic',
'URL': 'http://127.0.0.1:9200/',
}
}

Putting multiple such values into a single environment variable can still be
not pretty. Tooption to change the behaviour of ``by_defaults`` to generate
multiple specs for a dict::

set HAYSTACK_CONNECTIONS_DEFAULT_ENGINE="elastic"
set HAYSTACK_CONNECTIONS_DEFAULT_URL"elastic"
>>> confcollect.from_environ(by_defaults=DJANGO, nested_dicts=True)
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'elastic',
'URL': 'http://127.0.0.1:9200/',
}
}


**(not yet supported)** We can write inside a dict::

spec(read='SEARCH', convert=dict, write_dict='HAYSTACK_CONNECTIONS.default')


**(not yet supported)** We can read multiple values via regex::

spec(read_prefix='SEARCH_(.*)_(.*)', write_dict='HAYSTACK_CONNECTIONS.{0}.{1}')
# If there are dots in the names
spec(read_prefix='SEARCH_(.*)_(.*)', write_dict=('HAYSTACK_CONNECTIONS', '{0}', '{1}'))


**(Support reading nested dicts)** set DB="default=(ENGINE=mysql,HOST=localhost)"


Derivative settings
===================

Imagine that your app has to settings, ``REDIS_HOST`` and ``REDIS_PORT``. But
your deployment setup provides a single ``REDIS_URL`` environment variable.

We can wire this up::

set REDIS_URL="redis://localhost:4566/0"
>>> spec('REDIS_URL', 'REDIS_HOST', convert=parse_url('netloc'))
>>> spec('REDIS_URL', 'REDIS_PORT', parse_url('port'), )

Here we parse a different piece of information out of the url using the
``parse_url``helper.


**(not yet supported)** Pulling all elements of the URL into variables:

>>> spec('REDIS_URL', 'REDIS_{}', convert=parse_url)
>>> spec('REDIS_URL', 'REDIS_INFO', convert=parse_url) # REDIS_INFO would be dict


The other way around - taking multiple settings and making a url is also
sometimes necessary.


**(not yet supported)** This can be done using a regular format string::

confcollect.spec('BROKER_[HOST|DB_NAME]', format="redis://{HOST}/{DB_NAME}", write="BROKER_URL")

**(not yet supported)** Or, the build_url() helper will take a dict and
smartly recognize identifiers for host, port etc.::

spec('BROKER_(.*)', convert=build_url, write='BROKER_URL')
Release History

Release History

0.2.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
confcollect-0.2.3.tar.gz (6.0 kB) Copy SHA256 Checksum SHA256 Source Apr 14, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting