I have a typical Pyramid web application setup. The application directory (I don’t know what this directory is called in Pyramid?) contains the static, templates and ini.py files. In this directory I also created a directory called static_content that I use to store some special report templates.
In my view code I am using something like this to read the files in the sub-directories of the static_content directory:
f = open("/static_content/abc/report_template.tpt" , "r")
Then over in my init.py file I added a line:
config.add_static_view("static_content", "static_content")
I get an IO Error…..how do I fix this?
Regards,
Mark Huang
A leading slash in a file’s path means you’re giving it the full path (the file is at this exact location). If you want a relative path, take off the leading slash:
This tells it to follow that path from the current directory.
You may want to look at this question in order to build a relative path from the script file.