changeset 2891:7e4627efd98e

make wikidicts.Group() keep order for iterator and members() method
author Johannes Berg <johannes AT sipsolutions DOT net>
date Fri, 19 Oct 2007 00:11:23 +0200
parents 3db0e82be499
children 863060b2cfc5
files MoinMoin/wikidicts.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/wikidicts.py	Mon Oct 15 20:55:33 2007 +0200
+++ b/MoinMoin/wikidicts.py	Fri Oct 19 00:11:23 2007 +0200
@@ -92,14 +92,21 @@
     # strip free links markup if exists.
     regex = r'^ \* +(?:\[\[)?(?P<member>.+?)(?:\]\])? *$'
 
+    def __init__(self, request=None, pagename=None):
+        self._list = []
+        DictBase.__init__(self, request, pagename)
+
     def initFromText(self, text):
         for match in self.regex.finditer(text):
             member = match.group('member')
             self.addmember(member)
 
+    def __iter__(self):
+        return iter(self._list)
+
     def members(self):
         """ return the group's members """
-        return self.keys()
+        return self._list[:]
 
     def addmembers(self, members):
         """ add a list of members to the group """
@@ -109,6 +116,7 @@
     def addmember(self, member):
         """ add a member to the group """
         self[member] = 1
+        self._list.append(member)
 
     def has_member(self, member):
         """ check if the group has member <member> """