Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ecommerce
Commits
c02a9e03
Commit
c02a9e03
authored
Feb 21, 2018
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add private YML override support.
parent
57432017
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletions
+32
-1
ecommerce/settings/devstack.py
+32
-1
No files found.
ecommerce/settings/devstack.py
View file @
c02a9e03
...
...
@@ -53,7 +53,38 @@ PAYMENT_PROCESSOR_CONFIG = {
LANGUAGE_COOKIE_NAME
=
'openedx-language-preference'
#####################################################################
# Lastly, see if the developer has any local overrides.
# Lastly, see if the developer has any local
Python
overrides.
if
os
.
path
.
isfile
(
join
(
dirname
(
abspath
(
__file__
)),
'private.py'
)):
# noinspection PyUnresolvedReferences
from
.private
import
*
# pylint: disable=import-error
#####################################################################
# And - see if the developer has any local YAML overrides.
PRIVATE_YML_FILE
=
'private.yml'
def
_override_key_values
(
settings
,
overrides
):
"""
Override the values in settings using the values in overrides.
If overrides contains nested dictionaries, the dictionaries are recursively
followed down to the non-dict values and set, preserving other key/value
pairs in the dictionary.
Params:
settings (dict): Dictionary of Django settings.
overrides (dict): Dictionary of overrides for the Django settings.
"""
for
override
in
overrides
:
if
isinstance
(
overrides
[
override
],
dict
):
# The value is a dict. So continue down the override chain.
if
not
override
in
settings
:
settings
[
override
]
=
{}
_override_key_values
(
settings
[
override
],
overrides
[
override
])
else
:
# The value is a non-dict. So just set it.
settings
[
override
]
=
overrides
[
override
]
override_path
=
join
(
dirname
(
abspath
(
__file__
)),
PRIVATE_YML_FILE
)
if
os
.
path
.
isfile
(
override_path
):
with
codecs
.
open
(
override_path
,
encoding
=
'utf-8'
)
as
f
:
config_from_yaml
=
yaml
.
load
(
f
)
_override_key_values
(
vars
(),
config_from_yaml
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment