Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
99
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp
Commits
0dcf49bb
Commit
0dcf49bb
authored
4 years ago
by
plup
Browse files
Options
Downloads
Patches
Plain Diff
feature: removed settings module injection through a wrapper
parent
f833b2b2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!158
Load djangoldp conguration from YAML file
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoldp/conf/settings.py
+2
-28
2 additions, 28 deletions
djangoldp/conf/settings.py
with
2 additions
and
28 deletions
djangoldp/conf/settings.py
+
2
−
28
View file @
0dcf49bb
import
os
import
sys
import
yaml
from
django
import
conf
from
django.conf
import
LazySettings
from
django.conf
import
settings
as
django_settings
from
.
import
global_settings
try
:
...
...
@@ -10,37 +9,12 @@ try:
except
ImportError
:
from
django.utils.importlib
import
import_module
# Reference: https://github.com/django/django/blob/master/django/conf/__init__.py
def
configure
():
# catch djangoldp specific settings
settings_module
=
os
.
getenv
(
'
DJANGOLDP_SETTINGS
'
)
if
not
settings_module
:
raise
ImportError
(
'
Settings could not be imported because DJANGOLDP_SETTINGS is not set
'
)
# patch django.conf.settings
# ref: https://github.com/rochacbruno/dynaconf/blob/master/dynaconf/contrib/django_dynaconf_v2.py
# ref: https://docs.djangoproject.com/fr/2.2/topics/settings/#custom-default-settings
settings
=
LDPSettings
(
'
config.yml
'
)
lazy
=
LazySettings
()
lazy
.
configure
(
settings
)
class
Wrapper
(
object
):
def
__getattribute__
(
self
,
name
):
if
name
==
"
settings
"
:
return
lazy
else
:
return
getattr
(
conf
,
name
)
sys
.
modules
[
"
django.conf
"
]
=
Wrapper
()
# setup vars to resume django setup process
os
.
environ
[
'
DJANGO_SETTINGS_MODULE
'
]
=
settings_module
django_settings
.
configure
(
settings
)
class
LDPSettings
(
object
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment