Skip to content

Commit f1b0421

Browse files
committed
Temporary hack to avoid name collision without renaming the secrets app
1 parent 01b9d1a commit f1b0421

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

netbox/secrets/__init__.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# TODO: Rename the secrets app, probably
2+
# Python 3.6 introduced a standard library named "secrets," which obviously conflicts with this Django app. To avoid
3+
# renaming the app, we hotwire the components of the standard library that Django calls. (I don't like this any more
4+
# than you do, but it works for now.) The only references to the secrets modules are in django/utils/crypto.py.
5+
#
6+
# First, we copy secrets.compare_digest, which comes from the hmac module:
7+
from hmac import compare_digest
8+
9+
# Then, we instantiate SystemRandom and map its choice() function:
10+
from random import SystemRandom
11+
choice = SystemRandom().choice

0 commit comments

Comments
 (0)