This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Overview

Django-Multihost is a Django middleware that overrides Site ORM functionality and gets the current Site from the Host header. The code is loosely based on the work done by Bruce Kroeze here: django-threaded-multihost.

Description

The MultiHostMiddleware class contained in this app has 2 tasks:

  1. Upon middleware __init__(), it overrides SiteManager.get_current() with a multihost-aware version that reads the Host header from the request and attempts to find a matching Site (caches it if cache is enabled).
  2. Upon middleware process_request(), it sets the request into threadlocal storage and then uses the new SiteManager.get_current() functionality to retrieve the Site matching the Host header and sets it into the request instance. If a match is not found and MULTIHOST_AUTO_WWW is True (the default), it will attempt to modify the Host URL to add/remove www. and attempt the lookup again. If it still doesn’t find a matching Site, it redirects to MULTIHOST_REDIRECT_URL.

Requirements

  • Python 2.6 (May work with 2.3+, but untested - please report)
  • Django 1.2.x (May work with 1.0+, but untested - please report)

Installation

  1. Copy or symlink the multihost package into your django project directory or install it by running one of the following commands:

    python setup.py install

    or

    pip install django-multihost

    or

    easy_install django-multihost

  2. Add MULTIHOST_REDIRECT_URL to settings.py

  3. Add multihost.middleware.MultiHostMiddleware to your MIDDLEWARE_CLASSES in at the end of the list. If you find it isn’t working, move it up the list order as there may be a middleware conflict.

Note: Django does strange things (like sending requests to the wrong urls handler) when it is used in conjunction with debug_toolbar. To fix this problem, multihost must always be the last entry in MIDDLEWARE_CLASSES.

Advanced Settings

There are 2 settings that developers can use to override default functionality:

  • MULTIHOST_REDIRECT_URL: required; no default. The default middleware request processing will redirect to this URL in the case of Site lookup failure.
  • MULTIHOST_AUTO_WWW: optional; defaults to True. If the Site can’t be found that matches the incoming Host header exactly, this will automatically try removing/adding www. and searching again.

Notes

It is important to note that the MultiHostMiddleware middleware does database lookups against the Django tables corresponding to the Site model - in particular, against the domain field. In the default Django implementation (version 1.2.1 as of writing), the domain field is not indexed or unique and this may result in slower performance over time.

For this reason, web site/application developers should weigh the benefits and consider manually adding an index for the Site model’s domain field using standard database access tools.

Source

The latest source code can always be found here: github.com/jaddison/django-multihost

Credits

Django-Multihost is maintained by James Addison.

License

Django-Multihost is Copyright (c) 2010-2012, James Addison. It is free software, and may be redistributed under the terms specified in the LICENSE file.

Questions, Comments, Concerns:

Feel free to open an issue here: github.com/jaddison/django-multihost/issues

Release History

Release History

0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-multihost-0.3.macosx-10.8-intel.exe (71.8 kB) Copy SHA256 Checksum SHA256 any Windows Installer Dec 7, 2012
django-multihost-0.3.tar.gz (5.5 kB) Copy SHA256 Checksum SHA256 Source Dec 7, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting