ianb / pywebapp

Support library for Python Web Applications
19 stars 1 forks source link

Environment Variables in Config #2

Open kennethreitz opened 12 years ago

kennethreitz commented 12 years ago

(Assuming we want a non-dynamic configuration scheme)

We should provide a mechanism for injecting environment variables into static configurations (e.g. $PORT). This will enable explicit application portability in PaaS-style environments.

ianb commented 12 years ago

I think this would be a confusion of configuration. If an application is actually binding to a port (not the case with WSGI, but could be with other systems) then yes, that would be provided by the environment to the application, the application would not self-declare which port it would use. Right now that would be some value in webconfig, or in Silver Lining it was environmental variables.

When porting existing applications to this format, it is helpful to use environmental variables when they have a format that makes it easy to do environmental variable substitution. Something like Django actually has no problem, because you can just import values into your .py config file.

Also some stuff can be done with the sitecustomize.py files, if you need to tweak things to work around applications that expect to be configured in a manner unlike this format.