'Set the request\'s \'site_theme\' attribute based upon the current user.'

def process_request(self, request):

    preview_site_theme = get_user_preview_site_theme(request)
    if preview_site_theme:
        site_theme = preview_site_theme
    else:
        default_theme = None
        if settings.DEFAULT_SITE_THEME:
            default_theme = SiteTheme(site=request.site, theme_dir_name=settings.DEFAULT_SITE_THEME)
        site_theme = SiteTheme.get_theme(request.site, default=default_theme)
    request.site_theme = site_theme
