summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 64076d6)
raw | patch | inline | side by side (parent: 64076d6)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 30 Mar 2004 06:35:33 +0000 (06:35 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 30 Mar 2004 06:35:33 +0000 (06:35 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2232 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
doc/index.txt | patch | blob | history | |
roundup/cgi/MultiMapping.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index fed41aecb582143acd20b6ae0021be03bf34dd68..2d5748caeed5a60e498832de4e0d617ae2684d3b 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
2004-??-?? 0.7.0
Fixed:
- CSV export was busted
+- MultiMapping deviated from the Zope C implementation in a number of
+ places (thanks Toby Sargeant)
2004-03-27 0.7.0b2
diff --git a/doc/index.txt b/doc/index.txt
index 30955096e534fec4feec75095a1a307213c64b11..0860ac50b433d16d2f704e7efe25c3a503fba8d1 100644 (file)
--- a/doc/index.txt
+++ b/doc/index.txt
Roy Rapoport,
John P. Rouillard,
Ollie Rutherfurd,
+Toby Sargeant,
Florian Schulze,
Dougal Scott,
Stefan Seefeld,
index b528288766c99c9d6016e1f1357bdd7efa180563..583e2d797d1466c1358a97a0e084cf8cd4787376 100644 (file)
-import operator
-
class MultiMapping:
def __init__(self, *stores):
self.stores = list(stores)
+ self.stores.reverse()
+
def __getitem__(self, key):
for store in self.stores:
if store.has_key(key):
return store[key]
raise KeyError, key
+
+ def __setitem__(self, key, val):
+ self.stores[0][key] = val
+
_marker = []
+
def get(self, key, default=_marker):
for store in self.stores:
if store.has_key(key):
if default is self._marker:
raise KeyError, key
return default
+
def __len__(self):
- return reduce(operator.add, [len(x) for x in stores], 0)
+ return len(self.items())
+
+ def has_key(self, key):
+ for store in self.stores:
+ if store.has_key(key):
+ return 1
+ return 0
+
def push(self, store):
- self.stores.append(store)
+ self.stores = [store] + self.stores
+
def pop(self):
- return self.stores.pop()
+ if not len(self.stores):
+ return None
+ store, self.stores = self.stores[0], self.stores[1:]
+ return store
+
+ def keys(self):
+ return [ _[0] for _ in self.items() ]
+
+ def values(self):
+ return [ _[1] for _ in self.items() ]
+
+ def copy(self):
+ copy = MultiMapping()
+ copy.stores = [_.copy() for _ in self.stores]
+ return copy
+
+ def items(self):
+ l = []
+ seen = {}
+ for store in self.stores:
+ for k, v in store.items():
+ if not seen.has_key(k):
+ l.append((k, v))
+ seen[k] = 1
+ return l