configurator
Project description
making configuration phase, in your application. (Tiny version of almost pyramid’s configurator object)
# yourapplication.py from miniconfig import ConfiguratorCore class Configurator(ConfiguratorCore): def make_app(self): self.commit() return App(self.settings)
pluginA
# yourapplication/pluginA.py def includeme(config): config.settings["A"] = PluginA()
pluginB
# yourapplication/pluginB.py def includeme(config): config.include(".pluginA") config.settings["B"] = PluginB()
application user
from yourapplication import Configurator config = Configurator() config.include("yourapplication.pluginB") app = config.make_app()
Adding directives
directive means that action of configurator.
how to define and use directive
def hello(config, name): def register(): assert config.settings["foo"] == "foo" print("hello: {}".format(name)) config.action(register) config = Configurator(settings={"foo": "foo"}) config.add_directive("hello", hello) config.hello("foo")
it is also supported that to define directives by dotted name:
## foo/bar.py def hello(config): def register(): print("hai") config.action(register) ## yourapplication config = Configurator() config.add_directive("hello", "foo.bar:hello") config.hello() config.commit() # hai
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
miniconfig-0.1.3.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for miniconfig-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2adfe8196b01b47282fb75adcdc71d5216b7865c51ac2d5953433e9046d575d6 |
|
MD5 | ee738e4c0515779ee460addffddcd5e8 |
|
BLAKE2b-256 | 789dbef4d14056590e8e849e52c0f1ddb92099109fb3a1b84eae71d7983f37e0 |