changeset 4809:415338464695

Groups2009: Group._load_group() returns members and member_groups. Minor code refinements.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Sun, 14 Jun 2009 17:01:09 +0200
parents c54a1ba60873
children 3c0ce322472a
files MoinMoin/groups/backends/__init__.py MoinMoin/groups/backends/config_group.py MoinMoin/groups/backends/wiki_group.py
diffstat 3 files changed, 10 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/groups/backends/__init__.py	Sat Jun 13 21:11:38 2009 +0200
+++ b/MoinMoin/groups/backends/__init__.py	Sun Jun 14 17:01:09 2009 +0200
@@ -21,18 +21,12 @@
         self.request = request
         self.name = name
         self._backend = backend
-        self.members = None
-        self.member_groups = None
-
-        self._load_group()
+        self.members, self.member_groups = self._load_group()
 
     def _load_group(self):
         """
         Fill in self.members, self.member_groups with data retrieved from the backend.
         """
-
-        request = self.request
-
         members_final = set()
         member_groups = set()
 
@@ -42,8 +36,7 @@
             else:
                 members_final.add(member)
 
-        self.members = members_final
-        self.member_groups = member_groups
+        return members_final, member_groups
 
     def _contains(self, member, processed_groups):
         """
@@ -107,9 +100,9 @@
 
     def __repr__(self):
         return "<%s name=%s members=%s member_groups=%s>" % (self.__class__,
-                                                                   self.name,
-                                                                   self.members,
-                                                                   self.member_groups)
+                                                             self.name,
+                                                             self.members,
+                                                             self.member_groups)
 
 
 class BaseBackend(object):
--- a/MoinMoin/groups/backends/config_group.py	Sat Jun 13 21:11:38 2009 +0200
+++ b/MoinMoin/groups/backends/config_group.py	Sun Jun 14 17:01:09 2009 +0200
@@ -30,7 +30,7 @@
         return self.page_group_regex.match(group_name) and group_name in self._groups
 
     def __iter__(self):
-        return iter(self._groups.keys())
+        return self._groups.iterkeys()
 
     def __getitem__(self, group_name):
         return Group(request=self.request, name=group_name, backend=self)
--- a/MoinMoin/groups/backends/wiki_group.py	Sat Jun 13 21:11:38 2009 +0200
+++ b/MoinMoin/groups/backends/wiki_group.py	Sun Jun 14 17:01:09 2009 +0200
@@ -37,15 +37,14 @@
                 # TODO: fix up-to-date check mtime granularity problems
                 if cache_mtime > page_mtime:
                     # cache is uptodate
-                    self.members, self.member_groups = cache.content()
+                    return cache.content()
                 else:
                     raise caching.CacheError
             except caching.CacheError:
                 # either cache does not exist, is erroneous or not uptodate: recreate it
-
-                super(Group, self)._load_group()
-
-                cache.update((self.members, self. member_groups))
+                members, member_groups = super(Group, self)._load_group()
+                cache.update((members, member_groups))
+                return members, member_groups
         else:
             raise KeyError("There is no such group page %s" % group_name)