view roundup/cgi/MultiMapping.py @ 1003:f89b8d32291b

Hack hack hack... . Implemented security assertion idea punted to mailing list (pretty easy to back out if someone comes up with a better idea) so editing "my details" works again. Rationalised and cleaned up the actions in any case. . fixed some more display issues (stuff appearing when it should and shouldn't) . trying a nicer colouring scheme for the top level page . handle no grouping being specified . fixed journaltag so the logged-in user is journalled, not admin!
author Richard Jones <richard@users.sourceforge.net>
date Sun, 01 Sep 2002 12:18:41 +0000
parents 55ab0c5b49f9
children 53c600091f17
line wrap: on
line source

import operator

class MultiMapping:
    def __init__(self, *stores):
        self.stores = list(stores)
    def __getitem__(self, key):
        for store in self.stores:
            if store.has_key(key):
                return store[key]
        raise KeyError, key
    _marker = []
    def get(self, key, default=_marker):
        for store in self.stores:
            if store.has_key(key):
                return store[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)
    def push(self, store):
        self.stores.append(store)
    def pop(self):
        return self.stores.pop()


Roundup Issue Tracker: http://roundup-tracker.org/