changeset 4897:98a6aa0ce17e

merged moin/1.9-groups-dmilajevs
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 24 Jul 2009 14:08:56 +0200
parents c1ed36a3fd5e (current diff) 4cc429db5bd1 (diff)
children 19e9f1edb2f1
files
diffstat 5 files changed, 34 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/datastruct/backends/__init__.py	Fri Jul 24 10:22:35 2009 +0200
+++ b/MoinMoin/datastruct/backends/__init__.py	Fri Jul 24 14:08:56 2009 +0200
@@ -311,3 +311,9 @@
     def _retrieve_items(self, dict_name):
         raise NotImplementedError()
 
+    def get(self, key, default=None):
+        try:
+            return self[key]
+        except DictDoesNotExistError:
+            return default
+
--- a/MoinMoin/datastruct/backends/_tests/__init__.py	Fri Jul 24 10:22:35 2009 +0200
+++ b/MoinMoin/datastruct/backends/_tests/__init__.py	Fri Jul 24 14:08:56 2009 +0200
@@ -164,3 +164,18 @@
 
         assert u'SomeNotExistingDict' not in dicts
 
+    def test_get(self):
+        dicts = self.request.dicts
+
+        for dict_name in self.dicts:
+            assert dicts.get(dict_name)
+
+        assert u'SomeNotExistingDict' not in dicts
+        assert dicts.get(u'SomeNotExistingDict') is None
+
+        for dict_name, expected_dict in self.dicts.items():
+            test_dict = dicts[dict_name]
+            for key, value in expected_dict.items():
+                assert u'SomeNotExistingKey' not in test_dict
+                assert test_dict.get(u'SomeNotExistingKey') is None
+
--- a/MoinMoin/macro/__init__.py	Fri Jul 24 10:22:35 2009 +0200
+++ b/MoinMoin/macro/__init__.py	Fri Jul 24 14:08:56 2009 +0200
@@ -27,6 +27,7 @@
 from MoinMoin import action, config, util
 from MoinMoin import wikiutil, i18n
 from MoinMoin.Page import Page
+from MoinMoin.datastruct.backends.wiki_dicts import WikiDict
 
 
 names = ["TitleSearch", "WordIndex", "TitleIndex", "GoTo",
@@ -380,12 +381,18 @@
 
     def macro_GetVal(self, page=None, key=None):
         page = wikiutil.get_unicode(self.request, page, 'page')
-        if not self.request.user.may.read(page):
-            raise ValueError("You don't have enough rights on this page")
+
         key = wikiutil.get_unicode(self.request, key, 'key')
         if page is None or key is None:
             raise ValueError("You need to give: pagename, key")
-        d = self.request.dicts[page]
+
+        d = self.request.dicts.get(page, {})
+
+        # Check acl only if dictionary is defined on a wiki page.
+        if isinstance(d, WikiDict) and not self.request.user.may.read(page):
+            raise ValueError("You don't have enough rights on this page")
+
         result = d.get(key, '')
+
         return self.formatter.text(result)
 
--- a/MoinMoin/script/maint/cleancache.py	Fri Jul 24 10:22:35 2009 +0200
+++ b/MoinMoin/script/maint/cleancache.py	Fri Jul 24 14:08:56 2009 +0200
@@ -62,6 +62,6 @@
                              ('pagegroups', 'wiki'),
         ]
         for arena, scope in arena_scope_list:
-            for key caching.get_cache_list(request, arena, scope):
+            for key in caching.get_cache_list(request, arena, scope):
                 caching.CacheEntry(request, arena, key, scope=scope).remove()
 
--- a/setup.py	Fri Jul 24 10:22:35 2009 +0200
+++ b/setup.py	Fri Jul 24 14:08:56 2009 +0200
@@ -277,6 +277,8 @@
         'MoinMoin.auth',
         'MoinMoin.config',
         'MoinMoin.converter',
+        'MoinMoin.datastruct',
+        'MoinMoin.datastruct.backends',
         'MoinMoin.events',
         'MoinMoin.filter',
         'MoinMoin.formatter',