Question: I need to pull a configuration file in my main function:

```
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """ 

    parser = SafeConfigParser()
    ret = parser.read('/var/www/finance/corefinance/database.ini')
    connstring = parser.get('postgres', 'connstring')
    settings['sqlalchemy.url'] = connstring

```

The location of database.ini is one level up from the location of the **init**.py

I thought I could just use "../database.ini", but that doesn't work. The only thing that works is putting in the whole path. How can I avoid putting in a full path in this file?

Answer: 
Of course, within your **\_\_init\_\_.py** you can just define a variable using a string representation of your project's parent directory:

```
project_dir = '/var/www/finance/corefinance/'

```

But I'm sure you're not asking on SO to get an answer like that.

---

Another way is to add something similar to the following line within the `[app:main]` portion of your **development.ini** and **production.ini**:

```
project_dir = %(here)s/mycoolwebsite

```

Or maybe even just:

```
project_dir = %(here)s

```

Then in your **\_\_init\_\_.py** (and anywhere else you want to reference the project's parent directory) you can retrieve that value with:

```
project_dir = config.registry.settings['project_dir']

```

For more information on custom variables, see: <http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html#adding-a-custom-setting>
I finally got it to work based on @tag's idea:

```
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """ 

    parser = SafeConfigParser()
    iniloc = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'database.ini'))
    read_list = parser.read(iniloc)
    connstring = parser.get('postgres', 'connstring')
    settings['sqlalchemy.url'] = connstring

```