appconfig.py:
Read from configuration files easily without hurting performance.
USAGE:
During development you can load a config file either in .ini or .json format (by default app/private/appconfig.ini or app/private/appconfig.json)
The result is a dict holding the configured values. Passing reload=True is meant only for development: in production, leave reload to False and all values will be cached
from gluon.contrib.appconfig import AppConfig
myconfig = AppConfig(path_to_configfile, reload=False)
print myconfig['db']['uri']
The returned dict can walk with "dot notation" an arbitrarely nested dict
. print myconfig.take('db.uri')
You can even pass a cast function, i.e.
. print myconfig.take('auth.expiration', cast=int)
Once the value has been fetched (and casted) it won't change until the process is restarted (or reload=True is passed).
Please search in this group for more info.
Nico de Groot
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/1sBjyKQSY-U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.