diff --git a/ckan/lib/app_globals.py b/ckan/lib/app_globals.py index 400ceb0c546..f2a812d2942 100644 --- a/ckan/lib/app_globals.py +++ b/ckan/lib/app_globals.py @@ -1,6 +1,8 @@ ''' The application's Globals object ''' import logging +import time +from threading import Lock from paste.deploy.converters import asbool from pylons import config @@ -46,6 +48,7 @@ def set_global(key, value): ''' helper function for getting value from database or config file ''' model.set_system_info(key, value) setattr(app_globals, get_globals_key(key), value) + model.set_system_info('ckan.config_update', str(time.time())) # update the config config[key] = value log.info('config `%s` set to `%s`' % (key, value)) @@ -106,6 +109,8 @@ def get_config_value(key, default=''): app_globals.header_class = 'header-text-logo-tagline' + + class _Globals(object): ''' Globals acts as a container for objects available throughout the @@ -117,6 +122,18 @@ def __init__(self): 'app_globals' variable ''' self._init() + self._config_update = None + self._mutex = Lock() + + def _check_uptodate(self): + ''' check the config is uptodate needed when several instances are + running ''' + value = model.get_system_info('ckan.config_update') + if self._config_update != value: + if self._mutex.acquire(False): + reset() + self._config_update = value + self._mutex.release() def _init(self): self.favicon = config.get('ckan.favicon', '/images/icons/ckan.ico') diff --git a/ckan/lib/base.py b/ckan/lib/base.py index 88dfde1ab6d..04ad8e25e7c 100644 --- a/ckan/lib/base.py +++ b/ckan/lib/base.py @@ -28,6 +28,7 @@ from ckan.lib import i18n import lib.render import ckan.lib.helpers as h +import ckan.lib.app_globals as app_globals from ckan.plugins import PluginImplementations, IGenshiStreamFilter from ckan.lib.helpers import json import ckan.model as model @@ -204,6 +205,7 @@ class BaseController(WSGIController): def __before__(self, action, **params): c.__timer = time.time() c.__version__ = ckan.__version__ + app_globals.app_globals._check_uptodate() self._identify_user() i18n.handle_request(request, c) diff --git a/ckan/templates/user/read.html b/ckan/templates/user/read.html index 336faceba54..cc1d60f3835 100644 --- a/ckan/templates/user/read.html +++ b/ckan/templates/user/read.html @@ -84,10 +84,18 @@
- {{ _('You haven\'t created any datasets.') }} - {% link_for _('Create one now?'), controller='package', action='new' %}. -
+ + {% if c.is_myself %} ++ {{ _('You haven\'t created any datasets.') }} + {% link_for _('Create one now?'), controller='package', action='new' %}. +
+ {% else %} ++ {{ _('User hasn\'t created any datasets.') }} +
+ {% endif %} + {% endif %}