changeset 4855:e1a25e722434

Groups2009: Try ... except is used in place of if check for composite dicts and groups __getitem__. Test fix.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Fri, 17 Jul 2009 12:19:35 +0200
parents 77837e7984ea
children b8a22aa1854c
files MoinMoin/datastruct/backends/_tests/test_composite_dicts.py MoinMoin/datastruct/backends/composite_dicts.py MoinMoin/datastruct/backends/composite_groups.py
diffstat 3 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/datastruct/backends/_tests/test_composite_dicts.py	Fri Jul 17 12:19:32 2009 +0200
+++ b/MoinMoin/datastruct/backends/_tests/test_composite_dicts.py	Fri Jul 17 12:19:35 2009 +0200
@@ -30,8 +30,8 @@
 
         def dict_manager_init(self, request):
             return CompositeDicts(request,
-                                  CompositeDicts(request, self.one_dict),
-                                  CompositeDicts(request, self.other_dict))
+                                  ConfigDicts(request, self.one_dict),
+                                  ConfigDicts(request, self.other_dict))
 
 
 coverage_modules = ['MoinMoin.datastruct.backends.composite_dicts']
--- a/MoinMoin/datastruct/backends/composite_dicts.py	Fri Jul 17 12:19:32 2009 +0200
+++ b/MoinMoin/datastruct/backends/composite_dicts.py	Fri Jul 17 12:19:35 2009 +0200
@@ -27,8 +27,10 @@
         Get a dict by its name. First match counts.
         """
         for backend in self._backends:
-            if dict_name in backend:
+            try:
                 return backend[dict_name]
+            except DictDoesNotExistError:
+                pass
         raise DictDoesNotExistError(dict_name)
 
     def __contains__(self, dict_name):
--- a/MoinMoin/datastruct/backends/composite_groups.py	Fri Jul 17 12:19:32 2009 +0200
+++ b/MoinMoin/datastruct/backends/composite_groups.py	Fri Jul 17 12:19:35 2009 +0200
@@ -29,8 +29,10 @@
         @param group_name: name of the group [unicode]
         """
         for backend in self._backends:
-            if group_name in backend:
+            try:
                 return backend[group_name]
+            except GroupDoesNotExistError:
+                pass
         raise GroupDoesNotExistError(group_name)
 
     def __iter__(self):