Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPL-83: Change way settings are loaded #95

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,32 @@ Notes:

## Developer tools

### Adding Django Settings
If modules are using additional libraries that would usually require changes in `settings.py`,
these settings should be added within the module and not directly in assembly.
To do this, `django_settings.py` file with `SETTINGS` variable containing
a list of `SettingAttribute` objects has to be added to module (the same as in assembly module).
`SettingAttribute` provides information regarding setting `name`, setting `value` and conflict `resolving policy`.

#### Example:
```python
# django_settings.py
from openIMIS.modulesettingsloader import SettingsAttribute, SettingsAttributeConflictPolicy as setting_type

SETTINGS = [
SettingAttribute('CUSTOM_REQUIRED_SETTING', {'key': 'value'}, setting_type.MERGE_YIELD)
]
```
Is equivalent of assigning:
```python
# settings.py
CUSTOM_REQUIRED_SETTING = {'key': 'value'}
```
in `settings.py`.

Last parameter is used for resolving conflicts between overlying settings.
By default, values are merged (dictionaries are combined, lists concatenated), and if it's not possible
then already declared settings are not overridden.

### To create backend module skeleton in single command
* from `/openimis-be_py/openIMIS`:
Expand Down