[Web-SIG] Generic configuration

Manlio Perillo manlio_perillo at libero.it
Wed Mar 17 00:24:54 CET 2010

Alex Morega ha scritto:
> Hello,
> This is not really a WSGI question, it's more into general configuration, but I don't know of a better place to ask it.
> Paster config files allow you to hook up WSGI applications, middleware, and a server, plus some (undocumented?) magic configuration of the logging module. But what about random components, like a database? Ideally I'd like to specify a factory for database connections and give it some parameters; this would return a reference to a new database connection. I could then pass this reference to my wsgi app or middleware.
> Apparently the pattern is to perform this database configuration as part of a wsgi middleware, but that feels unnatural. Or one could do this outside of the paste configuration file, but that just splits the configuration needlessly into several pieces. Am I missing something obvious?

I use YAML with custom constructors:

There is a middleware:
that reads a list of configuration files to load from the WSGI environ
(I set this in the Nginx mod_wsgi) configuration, and merge all the
configuration in the WSGI environ.

Using custom YAML constructors it is possible to do something like:

It is also possible to configure the global python logging, create
temporary files and so on.

> Thanks,
> -- Alex


More information about the Web-SIG mailing list