I am currently writing a data collection service for several services. There are probably 5 different API endpoints with different hosts and port numbers. I wanted to create a settings file for this, but thought .ini should be the best place, or so I thought ...
My development.ini looks something like this:
[app:main]
use = egg:awesomeproject
auth.tkt = 'abc'
auth.secret = 'I love python'
mongodb.host = 'somehost'
mongodb.port= 6379
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
[user:sg:qa]
host = 127.0.0.1
port = 1234
[customer:sg:qa]
host = 127.0.0.2
port = 4567
I tried to access user sections inside the pyramid event, for example:
def add_api_path(event):
request = event.request
settings = request.registry.settings
_type = 'customer:sg:qa'
base_config = settings[_type]
But that did not work, because settings are actually a type of attribute [app:main]. Can someone teach me how to access Pyramid sections? I read about it in a different way using ConfigParser, but I wanted to ask if there is another simpler way in Pyramid.