def __init__(self, request=None, locale=None):
        # to avoid circular imports
        from kitsune.users.models import Profile

        self.request = request or WSGIRequest({'REQUEST_METHOD': 'bogus',
                                               'wsgi.input': None})
        self.locale, self.shortened_path = split_path(self.request.path_info)

        # We also need to check to see if locale is already given in the url,
        # as that serves as an override.
        if not self.locale and request:
            if request.user.is_anonymous():
                language = request.session.get(settings.LANGUAGE_COOKIE_NAME)
                if language:
                    self.locale = language
            else:
                try:
                    self.locale = Profile.objects.get(user=request.user).locale
                except Profile.DoesNotExist:
                    pass

        if locale:
            self.locale = locale
If request is omitted, fall back to a default locale.
dataset/ETHPy150Open mozilla/kitsune/kitsune/sumo/urlresolvers.py/Prefixer.__init__