Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
5a0d681f
Commit
5a0d681f
authored
4 years ago
by
plup
Browse files
Options
Downloads
Patches
Plain Diff
fix: reworked the parameter fetching in packages
parent
176fdcae
No related branches found
No related tags found
1 merge request
!158
Load djangoldp conguration from YAML file
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp/conf/global_settings.py
+1
-1
1 addition, 1 deletion
djangoldp/conf/global_settings.py
djangoldp/conf/settings.py
+22
-14
22 additions, 14 deletions
djangoldp/conf/settings.py
with
23 additions
and
15 deletions
djangoldp/conf/global_settings.py
+
1
−
1
View file @
5a0d681f
...
@@ -37,7 +37,7 @@ ALLOWED_HOSTS = []
...
@@ -37,7 +37,7 @@ ALLOWED_HOSTS = []
TIME_ZONE
=
'
America/Chicago
'
TIME_ZONE
=
'
America/Chicago
'
# If you set this to True, Django will use timezone-aware datetimes.
# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ
=
Fals
e
USE_TZ
=
Tru
e
# Language code for this installation. All choices can be found here:
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
# http://www.i18nguy.com/unicode/language-identifiers.html
...
...
This diff is collapsed.
Click to expand it.
djangoldp/conf/settings.py
+
22
−
14
View file @
5a0d681f
...
@@ -52,28 +52,36 @@ class LDPSettings(object):
...
@@ -52,28 +52,36 @@ class LDPSettings(object):
"""
Set a dict has current configuration.
"""
"""
Set a dict has current configuration.
"""
self
.
_config
=
value
self
.
_config
=
value
def
register
(
self
,
_list
,
name
):
def
fetch
(
self
,
attributes
):
"""
"""
Explore packages looking for a list of params to register within the server configuration.
Explore packages looking for a list of attributes within the server configuration.
It extends it with found elements and doesn
'
t manage duplications or collisions.
It returns all elements found and doesn
'
t manage duplications or collisions.
All elements are returned.
"""
"""
attr
=
[]
for
pkg
in
self
.
DJANGOLDP_PACKAGES
:
for
pkg
in
self
.
DJANGOLDP_PACKAGES
:
try
:
try
:
# import from an installed package
# import from an installed package
mod
=
import_module
(
f
'
{
pkg
}
.djangoldp_settings
'
)
mod
=
import_module
(
f
'
{
pkg
}
.djangoldp_settings
'
)
_list
.
extend
(
getattr
(
mod
,
name
))
logger
.
debug
(
f
'
Settings found for
{
pkg
}
in a installed package
'
)
logger
.
debug
(
f
'
{
name
}
found in installed package
{
pkg
}
'
)
except
(
ModuleNotFoundError
):
except
(
ModuleNotFoundError
,
NameError
):
try
:
try
:
# import from a local packages in a subfolder (same name the template is built this way)
# import from a local packages in a subfolder (same name the template is built this way)
mod
=
import_module
(
f
'
{
pkg
}
.
{
pkg
}
.djangoldp_settings
'
)
mod
=
import_module
(
f
'
{
pkg
}
.
{
pkg
}
.djangoldp_settings
'
)
_list
.
extend
(
getattr
(
mod
,
name
))
logger
.
debug
(
f
'
Settings found for
{
pkg
}
in a local package
'
)
logger
.
debug
(
f
'
{
name
}
found in local package
{
pkg
}
'
)
except
(
ModuleNotFoundError
):
except
(
ModuleNotFoundError
,
NameError
):
logger
.
debug
(
f
'
No settings found for
{
pkg
}
'
)
logger
.
info
(
f
'
No
{
name
}
found for package
{
pkg
}
'
)
break
pass
# looking for the attribute list in the module
try
:
attr
.
extend
(
getattr
(
mod
,
attributes
))
logger
.
debug
(
f
'
{
attributes
}
found in local package
{
pkg
}
'
)
except
(
NameError
):
logger
.
info
(
f
'
No
{
attributes
}
found for package
{
pkg
}
'
)
pass
return
attr
@property
@property
def
DJANGOLDP_PACKAGES
(
self
):
def
DJANGOLDP_PACKAGES
(
self
):
...
@@ -95,7 +103,7 @@ class LDPSettings(object):
...
@@ -95,7 +103,7 @@ class LDPSettings(object):
apps
.
extend
(
self
.
DJANGOLDP_PACKAGES
)
apps
.
extend
(
self
.
DJANGOLDP_PACKAGES
)
# add apps referenced in packages
# add apps referenced in packages
self
.
register
(
apps
,
'
INSTALLED_APPS
'
)
apps
.
extend
(
self
.
fetch
(
'
INSTALLED_APPS
'
)
)
return
apps
return
apps
...
@@ -110,7 +118,7 @@ class LDPSettings(object):
...
@@ -110,7 +118,7 @@ class LDPSettings(object):
middlewares
=
getattr
(
global_settings
,
'
MIDDLEWARE
'
)
middlewares
=
getattr
(
global_settings
,
'
MIDDLEWARE
'
)
# explore packages looking for middleware to reference
# explore packages looking for middleware to reference
self
.
register
(
middlewares
,
'
MIDDLEWARE
'
)
middlewares
.
extend
(
self
.
fetch
(
'
MIDDLEWARE
'
)
)
return
middlewares
return
middlewares
...
...
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