Changeset - 9adc0c1d9a87
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2010-12-29 12:18:49
marcin@python-works.com
Added optional cache into get_application settings
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/settings.py
Show inline comments
 
@@ -42,21 +42,22 @@ class SettingsModel(BaseModel):
 
            .filter(RhodeCodeSettings.app_settings_name == settings_key).scalar()
 
        if cache:
 
            r = r.options(FromCache("sql_cache_short",
 
                                          "get_setting_%s" % settings_key))
 
        return r
 

	
 
    def get_app_settings(self):
 
    def get_app_settings(self, cache=False):
 
        """Get's config from database, each config key is prefixed with 
 
        'rhodecode_' prefix, than global pylons config is updated with such 
 
        keys
 
        """
 

	
 
        ret = self.sa.query(RhodeCodeSettings)\
 
            .options(FromCache("sql_cache_short",
 
                           "get_hg_settings")).all()
 
        ret = self.sa.query(RhodeCodeSettings)
 

	
 
        if cache:
 
            ret = ret.options(FromCache("sql_cache_short", "get_hg_settings"))
 

	
 
        if not ret:
 
            raise Exception('Could not get application settings !')
 
        settings = {}
 
        for each in ret:
 
            settings['rhodecode_' + each.app_settings_name] = each.app_settings_value
0 comments (0 inline, 0 general)