Show More
@@ -23,6 +23,7 b' import logging' | |||||
23 | from collections import namedtuple |
|
23 | from collections import namedtuple | |
24 | from functools import wraps |
|
24 | from functools import wraps | |
25 |
|
25 | |||
|
26 | from rhodecode.lib import caches | |||
26 | from rhodecode.lib.caching_query import FromCache |
|
27 | from rhodecode.lib.caching_query import FromCache | |
27 | from rhodecode.lib.utils2 import ( |
|
28 | from rhodecode.lib.utils2 import ( | |
28 | Optional, AttributeDict, safe_str, remove_prefix, str2bool) |
|
29 | Optional, AttributeDict, safe_str, remove_prefix, str2bool) | |
@@ -201,22 +202,30 b' class SettingsModel(BaseModel):' | |||||
201 | return res |
|
202 | return res | |
202 |
|
203 | |||
203 | def get_all_settings(self, cache=False): |
|
204 | def get_all_settings(self, cache=False): | |
204 | q = self._get_settings_query() |
|
205 | def _compute(): | |
|
206 | q = self._get_settings_query() | |||
|
207 | if not q: | |||
|
208 | raise Exception('Could not get application settings !') | |||
|
209 | ||||
|
210 | settings = { | |||
|
211 | 'rhodecode_' + result.app_settings_name: result.app_settings_value | |||
|
212 | for result in q | |||
|
213 | } | |||
|
214 | return settings | |||
|
215 | ||||
205 | if cache: |
|
216 | if cache: | |
206 | repo = self._get_repo(self.repo) if self.repo else None |
|
217 | repo = self._get_repo(self.repo) if self.repo else None | |
207 | cache_key = ( |
|
218 | namespace = 'rhodecode_settings' | |
|
219 | cache_manager = caches.get_cache_manager( | |||
|
220 | 'sql_cache_short', namespace) | |||
|
221 | _cache_key = ( | |||
208 | "get_repo_{}_settings".format(repo.repo_id) |
|
222 | "get_repo_{}_settings".format(repo.repo_id) | |
209 |
if repo else "get_ |
|
223 | if repo else "get_app_settings") | |
210 | q = q.options(FromCache("sql_cache_short", cache_key)) |
|
|||
211 |
|
224 | |||
212 | if not q: |
|
225 | return cache_manager.get(_cache_key, createfunc=_compute) | |
213 | raise Exception('Could not get application settings !') |
|
|||
214 |
|
226 | |||
215 |
|
|
227 | else: | |
216 | 'rhodecode_' + result.app_settings_name: result.app_settings_value |
|
228 | return _compute() | |
217 | for result in q |
|
|||
218 | } |
|
|||
219 | return settings |
|
|||
220 |
|
229 | |||
221 | def get_auth_settings(self): |
|
230 | def get_auth_settings(self): | |
222 | q = self._get_settings_query() |
|
231 | q = self._get_settings_query() |
General Comments 0
You need to be logged in to leave comments.
Login now