Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
gregschmit committed Nov 13, 2019
1 parent b6e8e13 commit 58140c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion settings_model/__init__.py
@@ -1,2 +1,2 @@
__version__ = "0.5.0"
__version__ = "0.5.1"
default_app_config = "settings_model.apps.CustomConfig"
14 changes: 10 additions & 4 deletions settings_model/models.py
Expand Up @@ -85,15 +85,18 @@ def init(cls):
"""
See if we have settings. If so, read the actual settings values into it.
"""
print("settings_model: running settings init")
try:
s = cls.objects.filter(is_active=True).first()
if s:
s.read_settings()
elif cls.CREATE_INITIAL:
s = cls()
s.read_settings()
except DBError:
print("settings_model: db not ready")
except DBError as e:
print("settings_model: db not ready:")
print(e)
print("settings_model: ----------")
return

def read_settings(self):
Expand Down Expand Up @@ -226,14 +229,17 @@ def check_secret_key(cls):
Attempt to get the active settings, and if the secret key is set to the default
one, then create a new randomized secret key.
"""
print("settings_model: attempting to check the secret key...")
try:
s = cls.objects.filter(is_active=True).first()
if s and s.secret_key == "not-a-very-good-secret":
chars = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)"
s.secret_key = get_random_string(50, chars)
s.save()
except DBError:
print("settings_model: db not ready")
except DBError as e:
print("settings_model: db not ready:")
print(e)
print("settings_model: ----------")
return

def encode_setting(self, field):
Expand Down

0 comments on commit 58140c1

Please sign in to comment.