File: models.py

package info (click to toggle)
python-passlib 1.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,172 kB
  • ctags: 3,873
  • sloc: python: 21,883; makefile: 5
file content (36 lines) | stat: -rw-r--r-- 1,314 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""passlib.ext.django.models -- monkeypatch django hashing framework"""
#=============================================================================
# imports
#=============================================================================
# core
# site
# pkg
from passlib.context import CryptContext
from passlib.ext.django.utils import DjangoContextAdapter
# local
__all__ = ["password_context"]

#=============================================================================
# global attrs
#=============================================================================

#: adapter instance used to drive most of this
adapter = DjangoContextAdapter()

# the context object which this patches contrib.auth to use for password hashing.
# configuration controlled by ``settings.PASSLIB_CONFIG``.
password_context = adapter.context

#: hook callers should use if context is changed
context_changed = adapter.reset_hashers

#=============================================================================
# main code
#=============================================================================

# load config & install monkeypatch
adapter.load_model()

#=============================================================================
# eof
#=============================================================================