# function mapping User objects -> passlib user category. # may be overridden via ``settings.PASSLIB_GET_CATEGORY``. def _get_category(user): """default get_category() implementation""" if user.is_superuser: return "superuser" elif user.is_staff: return "staff" else: return None # object used to track state of patches applied to django. _manager = _PatchManager(log=logging.getLogger(__name__ + "._manager")) # patch status _patched = False #============================================================================= # applying & removing the patches #============================================================================= def _apply_patch(): """monkeypatch django's password handling to use ``passlib_context``, assumes the caller will configure the object. """ # # setup constants #
# configuration controlled by ``settings.PASSLIB_CONFIG``. password_context = CryptContext() # function mapping User objects -> passlib user category. # may be overridden via ``settings.PASSLIB_GET_CATEGORY``. def _get_category(user): """default get_category() implementation""" if user.is_superuser: return "superuser" elif user.is_staff: return "staff" else: return None # object used to track state of patches applied to django. _manager = _PatchManager(log=logging.getLogger(__name__ + "._manager")) # patch status _patched = False #=================================================================== # applying & removing the patches #=================================================================== def _apply_patch(): """monkeypatch django's password handling to use ``passlib_context``, assumes the caller will configure the object. """ # # setup constants # log.debug("preparing to monkeypatch 'django.contrib.auth' ...")