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.

  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):
+     def process_request(self, request):
          request.site_mode = get_site_mode(request)
  
Make sure that the site mode is populated on the request
## Code Before:
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)

## Instruction:
Make sure that the site mode is populated on the request
## Code After:
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)
