File: proxies.py

package info (click to toggle)
flask-security 5.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,448 kB
  • sloc: python: 23,247; javascript: 204; makefile: 138
file content (27 lines) | stat: -rw-r--r-- 749 bytes parent folder | download | duplicates (2)
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
# Copyright 2021-2024 by J. Christopher Wagner (jwag). All rights reserved.

import typing as t

from flask import current_app
from werkzeug.local import LocalProxy

if t.TYPE_CHECKING:  # pragma: no cover
    from passlib.context import CryptContext
    from .core import Security, UserDatastore

# Convenient references
_security: "Security" = LocalProxy(  # type: ignore
    lambda: current_app.extensions["security"]
)

_datastore: "UserDatastore" = LocalProxy(  # type:ignore
    lambda: _security.datastore
)

_pwd_context: "CryptContext" = LocalProxy(lambda: _security.pwd_context)  # type: ignore

_hashing_context: "CryptContext" = LocalProxy(  # type: ignore
    lambda: _security.hashing_context
)

DecoratedView = t.Callable[..., t.Any]