Skip to content

Commit

Permalink
made adjustments to the vocabulary feature
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyfadeev committed Oct 16, 2013
1 parent cadabff commit 7ee5ff9
Show file tree
Hide file tree
Showing 47 changed files with 1,562 additions and 1,731 deletions.
2 changes: 1 addition & 1 deletion askbot/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import askbot.conf.login_providers
import askbot.conf.access_control
import askbot.conf.site_modes
import askbot.conf.vocalbulary
import askbot.conf.words

#import main settings object
from askbot.conf.settings_wrapper import settings
Expand Down
23 changes: 17 additions & 6 deletions askbot/conf/settings_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,35 @@ def register(self, value):
self.__group_map[key] = group_key

def as_dict(self):
settings = cache.get('askbot-livesettings')
cache_key = get_bulk_cache_key()
settings = cache.get(cache_key)
if settings:
return settings
else:
self.prime_cache()
return cache.get('askbot-livesettings')
self.prime_cache(cache_key)
return cache.get(cache_key)

@classmethod
def prime_cache(cls, **kwargs):
def prime_cache(cls, cache_key, **kwargs):
"""reload all settings into cache as dictionary
"""
out = dict()
for key in cls.__instance.keys():
#todo: this is odd that I could not use self.__instance.items() mapping here
out[key] = cls.__instance[key].value
cache.set('askbot-livesettings', out)
cache.set(cache_key, out)


signals.configuration_value_changed.connect(ConfigSettings.prime_cache)
def get_bulk_cache_key():
from askbot.utils.translation import get_language
return 'askbot-settings-' + get_language()


def prime_cache_handler(*args, **kwargs):
cache_key = get_bulk_cache_key()
ConfigSettings.prime_cache(cache_key)


signals.configuration_value_changed.connect(prime_cache_handler)
#settings instance to be used elsewhere in the project
settings = ConfigSettings()
Loading

0 comments on commit 7ee5ff9

Please sign in to comment.