diff options
Diffstat (limited to 'Lib/bsddb')
-rw-r--r-- | Lib/bsddb/__init__.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py index 1ec6adc..5fc8a38 100644 --- a/Lib/bsddb/__init__.py +++ b/Lib/bsddb/__init__.py @@ -52,8 +52,9 @@ error = db.DBError # So bsddb.error will mean something... #---------------------------------------------------------------------- +import UserDict -class _DBWithCursor: +class _DBWithCursor(UserDict.DictMixin): """ A simple wrapper around DB that makes it look like the bsddbobject in the old module. It uses a cursor as needed to provide DB traversal. @@ -144,6 +145,14 @@ class _DBWithCursor: self._checkOpen() return self.db.sync() + def __iter__(self): + try: + yield self.first()[0] + next = self.next + while 1: + yield next()[0] + except _bsddb.DBNotFoundError: + return #---------------------------------------------------------------------- # Compatibility object factory functions |