from opendebates.utils import get_site_mode


class SiteModeMiddleware(object):
    """
    Gets or creates a SiteMode for the request, based on the hostname.
    """

    def process_view(self, request, view_func, view_args, view_kwargs):
        request.site_mode = get_site_mode(request)

from opendebates.utils import get_site_mode


class SiteModeMiddleware(object):
    """
    Gets or creates a SiteMode for the request, based on the hostname.
    """

    def process_request(self, request):
        request.site_mode = get_site_mode(request)

Make sure that the site mode is populated on the request
Make sure that the site mode is populated on the request

even if the request winds up getting dispatched to a flatpage.
