mozilla/socorro — pull request #989 by peterbe (2012-12-06 19:58:59+00:00)
Title: bug 816519 - middleware.wsgi app

@rhelmer r?

I learned something today. What you put in SetEnv in your apache config isn't passed to the xxx.wsgi script and this value isn't transferred into python's `os.environ`. Surprising, isn't it?!

If you want to have access to anything set with SetEnv it's instead passing into each request. For example, you can do this:

```python
#application = mywsgihandlerclass().application
_application = mywsgihandlerclass().application
import os
def application(env, start_response):
os.environ['MY_ENV'] = env['MY_ENV'] # requires `SetEnv MY_ENV somevalue` in apache
return _application(env, start_response)
```

However, this won't work in our case because we need `DEFAULT_SOCORRO_CONFIG_PATH` **before** we start passing requests from apache to python.

My hack, as you can see, is VERY mozilla socorro specific but I've confirmed that this works. You can now either put middleware.ini in /etc/socorro or in reporoot/config/.

I do worry a little bit about some poor guy some day trying to figure out where the config files are. We could opt to use reporoot/config/middleware.ini which could then do an include of /etc/socorro/middleware.ini or something.

Food for thought.