[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Memento - AttributeMementoBag.py:1.1.2.4

Casey Duncan casey@zope.com
Fri, 29 Mar 2002 12:50:29 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Memento
In directory cvs.zope.org:/tmp/cvs-serv4778

Modified Files:
      Tag: Zope-3x-branch
	AttributeMementoBag.py 
Log Message:
Revert back to oobtree implementation. Optimizing this requires a bit more
thought than I gave it.


=== Zope3/lib/python/Zope/App/OFS/Memento/AttributeMementoBag.py 1.1.2.3 => 1.1.2.4 ===
 """
 
-from Persistence.BTrees.IOBTree import IOBTree
+from Persistence.BTrees.OOBTree import OOBTree
 from IMementoBag import IMementoBag
 
 class AttributeMementoBag:
 
     """
-    Store memento bag data in the __membag__ attribute on a
+    Store memento bag data in the __memobag__ attribute on a
     IAttributeMementoStorable object.
     """
-
+    
     __implements__ = IMementoBag
 
     def __init__(self,obj):
-        if not hasattr(obj,'__memobag__'): obj.__memobag__ = IOBTree()
+        if not hasattr(obj,'__memobag__'): obj.__memobag__ = OOBTree()
         self.obj = obj
-        
-    def __getitem__(self, key):
-        try:
-            return self.obj.__memobag__[hash(key)]
-        except KeyError:
-            raise KeyError, key
-            
-    def get(self, key, default=None):
-        return self.obj.__memobag__.get(hash(key), default)
-    
-    def __setitem__(self, key, value):
-        self.obj.__memobag__[hash(key)] = value
 
-    def __delitem__(self, key):
-        try:
-            del self.obj.__memobag__[hash(key)]
-        except KeyError:
-            raise KeyError, key
+    def __getattr__(self,attr):
+        return getattr(self.obj.__memobag__,attr)