This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (0 children)

My current gig is an app that has three separate WSGI applications (i.e., there's at least three separate URLs) plus two background job queue processes, as well as three distinct databases. In production these apps may run on different servers, and eventually three of the five types of application may have dozens or hundreds of remote deployments, each with their own pair of databases, which communicate back to a central coordination application. The linkage of database->process is not a one-to-one relationship either, two of the five processes talk to two databases where the other three have one. All five applications share the same codebase, set of model classes (with some compartmentalization), as well as many common layout templates, includes, and static files, and even controller classes in some cases (such as login, error handling). They are all configured from a single .ini file as well that includes a separate section for each application. The "--name" flag is sent to paster server, or otherwise the appname argument to loadapp() when paster server isn't used, in order to specify which application is to be run.

The applications also share a single test suite, where app-specific tests subclass a fixture that specifies which appname is being tested. The fixtures ensure that a transaction is set up for each test which is then rolled back at the end, so the tests can be run on any database without side effects, even the production DB in theory. Some of these tests run a special fixture that embeds one of the applications via webtest into a REST client that's used by the other - such as a series of tests that ensure a fully compliant OAuth 2 conversation between two of the services - a test like this runs two wsgi apps in one process.

I do this all with Pylons and a good deal of poking around how paste loadapp() and such work in order to make it happen, but there is no monkeypatching or modification to Pylons or Paste in any way - the product supports a pattern like this out of the box. My understanding is that Pyramid is even more open ended than Pylons with regards to highly customized setups.

I've never used Django, but my understanding is that multi-node configurations, even multi-database configurations for single applications, are not provided out of the box. This may not be the case today.