Reduce number of redundant SQL queries

This commit is contained in:
Raphael Michel
2016-11-06 19:59:19 +01:00
parent 5aa3ff0616
commit 7b48a17b51
9 changed files with 161 additions and 145 deletions

View File

@@ -514,8 +514,15 @@ class SettingsSandbox:
self._event.settings.set(self._convert_key(key), value)
class GlobalSettingsObject:
class GlobalSettingsObject():
data_dict = None
def __init__(self):
self.settings = SettingsProxy(self, type=GlobalSetting)
self.setting_objects = GlobalSetting.objects
self.slug = '_global'
# This is a singleton-like object. Multiple objects can exist, but they share their state
if GlobalSettingsObject.data_dict:
self.__dict__ = GlobalSettingsObject.data_dict
else:
self.settings = SettingsProxy(self, type=GlobalSetting)
self.setting_objects = GlobalSetting.objects
self.slug = '_global'
GlobalSettingsObject.data_dict = self.__dict__