简体   繁体   中英

How to use a relative path for the ini file in pyramid.wsgi as argument of pyramid.paster.get_app?

How can I use a relative path for the production.ini file in the pyramid.wsgi file as argument of the paster.get_app() function?

I tried it and it keeps complaining that it can't find the file. In the error message, it has a starting forward slash added, so in case of the code below, I get an error saying that it can't find the file "/./production.ini".

from pyramid.paster import get_app, setup_logging
import logging

# THIS works: ini_path = '/home/bla/app/production.ini'
ini_path = "./production.ini" # This doesn't work, why not?
setup_logging(ini_path)
application = get_app(ini_path, 'main')

It's dependent on the working directory where the script (process) is executed. If you want it relative to the script itself then you might want os.path.join(os.path.dirname(__file__), 'production.ini') .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM