mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
default project is stored under constant key in local settings
This commit is contained in:
parent
ff1a694cad
commit
7b6d0d20df
3 changed files with 5 additions and 23 deletions
|
|
@ -17,6 +17,7 @@ PROJECT_SETTINGS_KEY = "project_settings"
|
|||
PROJECT_ANATOMY_KEY = "project_anatomy"
|
||||
LOCAL_SETTING_KEY = "local_settings"
|
||||
|
||||
DEFAULT_PROJECT_KEY = "__default_project__"
|
||||
|
||||
__all__ = (
|
||||
"M_OVERRIDEN_KEY",
|
||||
|
|
|
|||
|
|
@ -526,13 +526,7 @@ class MongoLocalSettingsHandler(LocalSettingsHandler):
|
|||
Data have 2 query criteria. First is key "type" stored in constant
|
||||
`LOCAL_SETTING_KEY`. Second is key "site_id" which value can be obstained
|
||||
with `get_local_site_id` function.
|
||||
|
||||
Because project specific values are stored by project name the default
|
||||
project would have key `None` which is not allowed. Because of that is
|
||||
`None` replaced with `default_project_key` value on save and the key
|
||||
is replaced with `None` of load.
|
||||
"""
|
||||
default_project_key = "__default_project__"
|
||||
|
||||
def __init__(self, local_site_id=None):
|
||||
# Get mongo connection
|
||||
|
|
@ -571,12 +565,6 @@ class MongoLocalSettingsHandler(LocalSettingsHandler):
|
|||
"""
|
||||
data = data or {}
|
||||
|
||||
# Replace key `None` (default project values) with constant string
|
||||
if "projects" in data and None in data["projects"]:
|
||||
data["projects"][self.default_project_key] = (
|
||||
data["projects"].pop(None)
|
||||
)
|
||||
|
||||
self.local_settings_cache.update_data(data)
|
||||
|
||||
self.collection.replace_one(
|
||||
|
|
@ -601,13 +589,5 @@ class MongoLocalSettingsHandler(LocalSettingsHandler):
|
|||
})
|
||||
|
||||
self.local_settings_cache.update_from_document(document)
|
||||
data = self.local_settings_cache.data
|
||||
if (
|
||||
"projects" in data
|
||||
and self.default_project_key in data["projects"]
|
||||
):
|
||||
data["projects"][None] = data["projects"].pop(
|
||||
self.default_project_key
|
||||
)
|
||||
|
||||
return self.local_settings_cache.data_copy()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ from .constants import (
|
|||
|
||||
SYSTEM_SETTINGS_KEY,
|
||||
PROJECT_SETTINGS_KEY,
|
||||
PROJECT_ANATOMY_KEY
|
||||
PROJECT_ANATOMY_KEY,
|
||||
DEFAULT_PROJECT_KEY
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -402,7 +403,7 @@ def apply_local_settings_on_anatomy_settings(
|
|||
return
|
||||
|
||||
current_platform = platform.system().lower()
|
||||
local_defaults = local_project_settings.get(None)
|
||||
local_defaults = local_project_settings.get(DEFAULT_PROJECT_KEY)
|
||||
root_data = anatomy_settings["roots"]
|
||||
if local_defaults and "roots" in local_defaults:
|
||||
for root_name, path in local_defaults["roots"].items():
|
||||
|
|
@ -411,7 +412,7 @@ def apply_local_settings_on_anatomy_settings(
|
|||
anatomy_settings["roots"][root_name][current_platform] = (
|
||||
path
|
||||
)
|
||||
if project_name is None:
|
||||
if project_name == DEFAULT_PROJECT_KEY:
|
||||
return
|
||||
|
||||
local_projects = local_project_settings.get(project_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue