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:
Alfredo Deza 2010-12-02 21:39:20 -05:00
parent 0e11c74731
commit 21d41e7fa3
8 changed files with 39 additions and 2 deletions

2
TODO
View File

@ -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

View File

@ -2,6 +2,7 @@ README
setup.cfg
setup.py
pecan/__init__.py
pecan/configuration.py
pecan/decorators.py
pecan/hooks.py
pecan/jsonify.py

View File

@ -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

View File

@ -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

23
pecan/configuration.py Executable file
View File

@ -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__()

View File

@ -0,0 +1,2 @@
from development import Development
from test import Test

View File

@ -0,0 +1,5 @@
from pecan.configuration import PecanConfig
class Development(PecanConfig):
pass

View File

@ -0,0 +1,5 @@
from pecan.configuration import PecanConfig
class Test(PecanConfig):
pass