[ckan-changes] commit/ckan: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Tue Oct 25 15:46:40 UTC 2011
2 new commits in ckan:
https://bitbucket.org/okfn/ckan/changeset/630df60885c6/
changeset: 630df60885c6
branch: release-v1.5
user: dread
date: 2011-10-25 15:39:27
summary: [config][xs]: Tidy up comments.
affected #: 1 file
diff -r a552ce0a2ea53f35174a8781e17e4871fa6b23c7 -r 630df60885c66b64786c8a2ea46b690bb1ee224f ckan/config/deployment.ini_tmpl
--- a/ckan/config/deployment.ini_tmpl
+++ b/ckan/config/deployment.ini_tmpl
@@ -180,12 +180,10 @@
#ckan.recaptcha.privatekey =
# Locale/languages
-# TODO: Figure out a nicer way to get this. From the .ini?
-# Order these by number of people speaking it in Europe:
-# http://en.wikipedia.org/wiki/Languages_of_the_European_Union#Knowledge
-# (or there abouts)
ckan.locale_default = en
#ckan.locales_offered =
+# Default order is roughly by number of people speaking it in Europe:
+# http://en.wikipedia.org/wiki/Languages_of_the_European_Union#Knowledge
ckan.locale_order = en de fr it es pl ru nl sv no cs_CZ hu pt_BR fi bg ca sq
ckan.locales_filtered_out = el
https://bitbucket.org/okfn/ckan/changeset/945e2a6ce74f/
changeset: 945e2a6ce74f
branch: release-v1.5
user: dread
date: 2011-10-25 17:20:40
summary: [controllers,lib]: #1321 flash messages and etag cache interaction fixed.
affected #: 4 files
diff -r 630df60885c66b64786c8a2ea46b690bb1ee224f -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 ckan/controllers/home.py
--- a/ckan/controllers/home.py
+++ b/ckan/controllers/home.py
@@ -44,9 +44,11 @@
@staticmethod
def _home_cache_key():
'''Calculate the etag cache key for the home page.'''
+ # a change to the data means the group package amounts may change
+ latest_revision_id = model.repo.youngest_revision().id
user_name = c.user
language = get_lang()
- cache_key = str(hash((user_name, language)))
+ cache_key = str(hash((user_name, language, latest_revision_id)))
return cache_key
@proxy_cache(expires=cache_expires)
diff -r 630df60885c66b64786c8a2ea46b690bb1ee224f -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 ckan/lib/cache.py
--- a/ckan/lib/cache.py
+++ b/ckan/lib/cache.py
@@ -7,6 +7,7 @@
from pylons.decorators.util import get_pylons
from pylons.controllers.util import etag_cache as pylons_etag_cache
import pylons.config
+from ckan.lib.helpers import are_there_flash_messages
__all__ = ["ckan_cache", "get_cache_expires"]
@@ -210,5 +211,6 @@
return cache_expires
def etag_cache(page_hash):
- if cache_validation_enabled:
+ # don't cache if there are flash messages to show (#1321)
+ if cache_validation_enabled and not are_there_flash_messages():
pylons_etag_cache(page_hash)
diff -r 630df60885c66b64786c8a2ea46b690bb1ee224f -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 ckan/lib/helpers.py
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -105,6 +105,10 @@
session.save()
return [Message(*m) for m in messages]
+ def are_there_messages(self):
+ from pylons import session
+ return bool(session.get(self.session_key))
+
_flash = _Flash()
def flash_notice(message, allow_html=False):
@@ -116,6 +120,9 @@
def flash_success(message, allow_html=False):
_flash(message, category='success', allow_html=allow_html)
+def are_there_flash_messages():
+ return _flash.are_there_messages()
+
# FIXME: shouldn't have to pass the c object in to this.
def nav_link(c, text, controller, **kwargs):
highlight_actions = kwargs.pop("highlight_actions",
diff -r 630df60885c66b64786c8a2ea46b690bb1ee224f -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 ckan/tests/functional/test_home.py
--- a/ckan/tests/functional/test_home.py
+++ b/ckan/tests/functional/test_home.py
@@ -32,21 +32,34 @@
assert 'Could not change language' not in res
def test_calculate_etag_hash(self):
+ # anything that changes the home page appearance should change the
+ # etag hash
c.user = 'test user'
get_hash = HomeController._home_cache_key
- hash_1 = get_hash()
- hash_2 = get_hash()
- self.assert_equal(hash_1, hash_2)
+ hashes = [get_hash(), get_hash()]
+ self.assert_equal(hashes[0], hashes[1])
+ def assert_hash_changed(hashes):
+ current_hash = get_hash()
+ assert current_hash != hashes[-1]
+ hashes.append(current_hash)
+
+ # login as a different user
c.user = 'another user'
- hash_3 = get_hash()
- assert hash_2 != hash_3
+ assert_hash_changed(hashes)
+ # add a package to a group
+ rev = model.repo.new_revision()
+ model.Group.by_name(u'roger').add_package_by_name(u'warandpeace')
+ model.repo.commit_and_remove()
+ assert_hash_changed(hashes)
+
+ # flash message is not cached, but this is done in ckan/lib/cache
+
# I can't get set_lang to work and deliver correct
# result to get_lang, so leaving it commented
## set_lang('fr')
-## hash_4 = get_hash()
-## assert hash_3 != hash_4
+## assert_hash_changed(hashes)
@search_related
def test_packages_link(self):
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list