class DBList(MutableSequence, Persistent): def __init__(self, source=None): self.plist = ZPersistentList() if source is not None: self.extend(source) # TODO: extend the plist instead, after # validating the types of the items in source def __getitem__(self, index): return self.plist[index] def __setitem__(self, index, value): if not isinstance(value, (basestring, int, long, bool, type(None), DBDict, DBList)): raise TypeError("Values can only be those supported by the ZODB backend.") self.plist[index] = value def __delitem__(self, index): del self.plist[index] def insert(self, index, value): if not isinstance(value, (basestring, int, long, bool, type(None), DBDict, DBList)): raise TypeError("Values can only be those supported by the ZODB backend.") self.plist.insert(index, value) def __len__(self): return len(self.plist) def __iter__(self): return self.plist.__iter__() def __contains__(self, value): return self.plist.__contains__(value)