Commit 30a634e0 authored by Raymond Hettinger's avatar Raymond Hettinger

SF patch #674396: Apply UserDict.DictMixin to expand dbshelve and dbojb

   to have a full dictionary interface.
parent 35ad641b
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# #
import db import db
from UserDict import DictMixin
class DBEnv: class DBEnv:
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
...@@ -85,7 +86,7 @@ class DBEnv: ...@@ -85,7 +86,7 @@ class DBEnv:
return apply(self._cobj.set_encrypt, args, kwargs) return apply(self._cobj.set_encrypt, args, kwargs)
class DB: class DB(DictMixin):
def __init__(self, dbenv, *args, **kwargs): def __init__(self, dbenv, *args, **kwargs):
# give it the proper DBEnv C object that its expecting # give it the proper DBEnv C object that its expecting
self._cobj = apply(db.DB, (dbenv._cobj,) + args, kwargs) self._cobj = apply(db.DB, (dbenv._cobj,) + args, kwargs)
......
...@@ -30,6 +30,7 @@ storage. ...@@ -30,6 +30,7 @@ storage.
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import cPickle import cPickle
from UserDict import DictMixin
try: try:
# For Python 2.3 # For Python 2.3
from bsddb import db from bsddb import db
...@@ -75,7 +76,7 @@ def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH, ...@@ -75,7 +76,7 @@ def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH,
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
class DBShelf: class DBShelf(DictMixin):
""" """
A shelf to hold pickled objects, built upon a bsddb DB object. It A shelf to hold pickled objects, built upon a bsddb DB object. It
automatically pickles/unpickles data objects going to/from the DB. automatically pickles/unpickles data objects going to/from the DB.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment