I have a python script that serves as an additional wrapper around tummy's memcached python wrapper. I have something like this:
class CacheIt(object):
def __init__(self, host=<hostname>, port=11211, **kwargs):
...
I want to be able to retrieve the memcached hostname from my ini file, but I don't want to specify which file because it may be taken from development.ini or production.ini or test.ini. I need the "finding" of the current ini file to be dynamic, meaning the application should know what the current ini file is and hence retrieve the hostname from the settings.
I can't use thread locals get_current_request and in turn to retrieve the settings file because the return value is None at application startup time (I attach an instance of my class to a NewRequest event).
This:
from paste.deploy.loadwsgi import appconfig
config = appconfig('config:development.ini', 'myapp', relative_to='.')
Still, I need to know the path first before I can use this. That means if I use this, I need to change the value of development.ini to production.ini everytime I deploy and to test.ini if I test. Surely there has to be a better way to do this.