# Path: shrubbery/authentication/exceptions.py
# class AuthenticationError(Exception): pass
# 
# class Http403(Exception): pass
# 
# Path: shrubbery/conf/base.py
# class Setting(object):
# class Registry(object):
# class SettingsBase(type):
# class Settings(object):
#     def __init__(self, validators=None, legacy_setting=None, help=None, resolve_callable=False, **kwargs):
#     def normalize(self, value):
#     def __get__(self, instance, cls=None):
#     def __set__(self, instance, value):
#     def __delete__(self, instance):
#     def __init__(self):
#     def __getitem__(self, module_name):
#     def __getattr__(self, name):
#     def __new__(cls, name, bases, attribs):     
#     def instance(cls):
#     def configure(cls, config):
#     def __init__(self, config=None):
#     def __iter__(self):
#     def __getitem__(self, name):
#     def __setitem__(self, name, value):
#     def __delitem__(self, name):
#     def as_dict(self):
#     def load(self, config):
#     def validate(self):
#     def app_module(self):
#     def app_label(self):
#     def missing_setting(self, setting):


import threading
from functools import wraps
from django.utils.importlib import import_module
from shrubbery.authentication.exceptions import AuthenticationError, Http403
from shrubbery.conf import settings
            user = self.root
        return Sudo(self, user)
        
    def is_anonymous(self, user):
        return user is self.anonymous
        
    def login(self, request, user):
        self.set_user(request, user)
        
    def logout(self, request):
        self.set_user(request, self.anonymous)
        
    def get_user_id(self, user):
        raise NotImplemented()
        
    def get_user_by_id(self, id):
        raise NotImplemented()
        
    def set_user(self, request, user=_unset):
        if user is not _unset:
            self.user = user
        if self.user:
            request.session[self.session_key] = self.get_user_id(self.user)
        elif self.session_key in request.session:
            del request.session[self.session_key]
        
    def get_user(self, request):
        if self.session_key in request.session:
            try:
                return self.get_user_by_id(request.session[self.session_key])

# Path: shrubbery/authentication/exceptions.py
# class AuthenticationError(Exception): pass
# 
# class Http403(Exception): pass
# 
# Path: shrubbery/conf/base.py
# class Setting(object):
# class Registry(object):
# class SettingsBase(type):
# class Settings(object):
#     def __init__(self, validators=None, legacy_setting=None, help=None, resolve_callable=False, **kwargs):
#     def normalize(self, value):
#     def __get__(self, instance, cls=None):
#     def __set__(self, instance, value):
#     def __delete__(self, instance):
#     def __init__(self):
#     def __getitem__(self, module_name):
#     def __getattr__(self, name):
#     def __new__(cls, name, bases, attribs):     
#     def instance(cls):
#     def configure(cls, config):
#     def __init__(self, config=None):
#     def __iter__(self):
#     def __getitem__(self, name):
#     def __setitem__(self, name, value):
#     def __delitem__(self, name):
#     def as_dict(self):
#     def load(self, config):
#     def validate(self):
#     def app_module(self):
#     def app_label(self):
#     def missing_setting(self, setting):


# Path: shrubbery/authentication/contexts.py
import threading
from functools import wraps
from django.utils.importlib import import_module
from shrubbery.authentication.exceptions import AuthenticationError, Http403
from shrubbery.conf import settings

            user = self.root
        return Sudo(self, user)
        
    def is_anonymous(self, user):
        return user is self.anonymous
        
    def login(self, request, user):
        self.set_user(request, user)
        
    def logout(self, request):
        self.set_user(request, self.anonymous)
        
    def get_user_id(self, user):
        raise NotImplemented()
        
    def get_user_by_id(self, id):
        raise NotImplemented()
        
    def set_user(self, request, user=_unset):
        if user is not _unset:
            self.user = user
        if self.user:
            request.session[self.session_key] = self.get_user_id(self.user)
        elif self.session_key in request.session:
            del request.session[self.session_key]
        
    def get_user(self, request):
        if self.session_key in request.session:
            try:
                return self.get_user_by_id(request.session[self.session_key])

            except (AuthenticationError, ValueError) as e: