feeling confident this is the right way towards nice configuration in pecan. This commit adds a config module within the pecan-base template and adds a configuration module to pecan to handle configuration stuff.
This commit is contained in:
parent
0e11c74731
commit
21d41e7fa3
2
TODO
2
TODO
|
@ -29,4 +29,4 @@ TODO for Release 0.1
|
|||
- define some standard configuration options
|
||||
. host, port, number of threads, etc.
|
||||
|
||||
* Updated template project, which shows off more features, including config
|
||||
* Updated template project, which shows off more features, including config
|
||||
|
|
|
@ -2,6 +2,7 @@ README
|
|||
setup.cfg
|
||||
setup.py
|
||||
pecan/__init__.py
|
||||
pecan/configuration.py
|
||||
pecan/decorators.py
|
||||
pecan/hooks.py
|
||||
pecan/jsonify.py
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
WebOb == 1.0.0
|
||||
WebCore == 1.0.0
|
||||
simplegeneric == 0.7
|
||||
Kajiki == 0.3.1
|
||||
Paste == 1.7.5.1
|
||||
PasteScript == 1.7.3
|
||||
formencode == 1.2.2
|
|
@ -17,4 +17,4 @@ def make_app(root, static_root=None, debug=False, errorcfg={}, **kw):
|
|||
app = ErrorMiddleware(app, debug=debug, **errorcfg)
|
||||
if static_root:
|
||||
app = Cascade([StaticURLParser(static_root), app])
|
||||
return app
|
||||
return app
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
|
||||
|
||||
class PecanConfig(object):
|
||||
"""Base configuration object for Pecan. It provides
|
||||
settings that can be overriden."""
|
||||
|
||||
port = '8080'
|
||||
host = '0.0.0.0'
|
||||
threads = 1
|
||||
|
||||
|
||||
|
||||
def _find_config(name):
|
||||
for config in _sub_classes():
|
||||
if name == config.__name__:
|
||||
return config
|
||||
|
||||
|
||||
def _sub_classes():
|
||||
return PecanConfig.__subclasses__()
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
from development import Development
|
||||
from test import Test
|
|
@ -0,0 +1,5 @@
|
|||
from pecan.configuration import PecanConfig
|
||||
|
||||
class Development(PecanConfig):
|
||||
pass
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
from pecan.configuration import PecanConfig
|
||||
|
||||
class Test(PecanConfig):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue