-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduce
nautobot.setup()
function (#5532)
* Fix #5531 - reintroduce nautobot.setup() function * Re-add sentinel against repeated initialization * Eliminate duplicate pylint call
- Loading branch information
1 parent
5622dbe
commit a762466
Showing
8 changed files
with
55 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Re-added `nautobot.setup()` function mistakenly removed in 2.2.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Removed `nautobot-server pylint` management command from the `example_app`, as pylint can be invoked directly with an appropriate `--init-hook` instead. |
Empty file.
Empty file.
23 changes: 0 additions & 23 deletions
23
examples/example_app/example_app/management/commands/pylint.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,35 @@ | ||
from importlib import metadata | ||
import logging | ||
import os | ||
|
||
import django | ||
|
||
# Primary package version | ||
__version__ = metadata.version(__name__) | ||
|
||
# Sentinel to make sure we only initialize once. | ||
__initialized = False | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def setup(config_path=None): | ||
"""Similar to `django.setup()`, this configures Django with the appropriate Nautobot settings data.""" | ||
from nautobot.core.cli import get_config_path, load_settings | ||
|
||
global __initialized | ||
|
||
if __initialized: | ||
return | ||
|
||
if config_path is None: | ||
config_path = get_config_path() | ||
|
||
# Point Django to our 'nautobot_config' pseudo-module that we'll load from the provided config path | ||
os.environ["DJANGO_SETTINGS_MODULE"] = "nautobot_config" | ||
|
||
load_settings(config_path) | ||
django.setup() | ||
|
||
logger.info("Nautobot initialized!") | ||
__initialized = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters