Slight bugfixes; returning from a remove is unpossible.

This commit is contained in:
Jeremy Fincher 2004-08-11 05:48:55 +00:00
parent c941521ba0
commit 12ee483f7a

View File

@ -40,6 +40,7 @@ import supybot.fix as fix
import csv import csv
import math import math
import sets import sets
import random
import supybot.cdb as cdb import supybot.cdb as cdb
import supybot.utils as utils import supybot.utils as utils
@ -251,7 +252,7 @@ class CdbMapping(MappingInterface):
class DB(object): class DB(object):
Mapping = None Mapping = 'flat' # This is a good, sane default.
Record = None Record = None
def __init__(self, filename, Mapping=None, Record=None): def __init__(self, filename, Mapping=None, Record=None):
if Record is not None: if Record is not None:
@ -280,8 +281,7 @@ class DB(object):
return self.map.add(s) return self.map.add(s)
def remove(self, id): def remove(self, id):
s = self.map.remove(id) self.map.remove(id)
return self._newRecord(id, s)
def __iter__(self): def __iter__(self):
for (id, s) in self.map: for (id, s) in self.map:
@ -293,6 +293,9 @@ class DB(object):
if p(record): if p(record):
yield record yield record
def random(self):
return random.choice(self)
def flush(self): def flush(self):
self.map.flush() self.map.flush()