Skip to main content
PyPI - License Pipeline status Test code coverage PyPI

Clor

Clor is a tiny wrapper around logging configuration system [1], which allows its reuse for general application configuration. The name was coined this way: “configurator” → “c10r” → “clor”.

Usage

Normally there’s a configuration module (e.g. envconf.py), or a YAML file. Here is a CherryPy example:

base = {
  'global' : {
    'server.socket_host' : '127.0.0.1',
    'server.socket_port' : 8080,
    'server.thread_pool' : 8
  },
  'app' : {
    'api' : {
      '/' : {
        'request.dispatch' : {
          '()' : 'cherrypy._cpdispatch.MethodDispatcher'
        }
      }
    }
  }
}

production = (base, {
  'global' : {
    'server.socket_host' : '0.0.0.0',
    'server.thread_pool' : 16,
    'tools.auth_basic.on'            : True,
    'tools.auth_basic.realm'         : 'App',
    'tools.auth_basic.checkpassword' : 'ext://someapp.password.checker'
  },
})

development = (base, {
  'global' : {
    'server.thread_pool' : None,
  },
  'app' : {
    'api' : {
      '/' : {
        'tools.response_headers.on'      : True,
        'tools.response_headers.headers' : [('Access-Control-Allow-Origin', '*')]
      }
    },
    'api2' : 'cfg://app.api'
  }
})

A few observations:

  • Nest dictionaries are merged recursively

  • logging’s ext pseudo-protocols

  • logging’s cfg pseudo-protocols

  • logging’s instantiation with () key

  • Keys having None value are removed

Then in your bootstrapping code you can do:

import clor

from . import envconf


config = clor.configure(*getattr(envconf, 'production'))

cherrypy.config.update(config)
cherrypy.tree.mount(ApiApplication(), '/api', config['app']['api'])

Metadata

Release files for Clor 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Clor 0.4.0
File Size Uploaded
Clor-0.4.0.tar.gz 4.8 kB Details

Release files / Clor-0.4.0.tar.gz

Download URL Clor-0.4.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a74af86685e05f8db4230f4ae0703a5604b602133edcc027a4a7d62a672b49d2
BLAKE2b-256 checksum
How to use checksums
f702d9c4e744d7bfe331b7b76ca455753330618ff4ae1670a408a2df8e99480e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.4.0 This release

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page