I know you can do redirection based on the domain or path to rewrite the URI to point at a site-specific location and I’ve also seen some brutish if and elif statements for every site as shown in the following code, which I would like to avoid.
if site == 'site1': ... elif site == 'site2: ...
What are some good and clever ways of running multiple sites from a single, common Python web framework (i.e., Pylons, TurboGears, etc)?
Django has this built in. See the sites framework.
As a general technique, include a ‘host’ column in your database schema attached to the data you want to be host-specific, then include the
HostHTTP header in the query when you are retrieving data.