Permalink
Browse files

plumb __setitem__ in ZODBPart and set _p_changed

  • Loading branch information...
1 parent c42ecf4 commit bc6ae4d5dc796a3de2279be87f2f031917134e6f Robert Niederreiter committed May 26, 2011
Showing with 32 additions and 0 deletions.
  1. +6 −0 src/node/ext/zodb/__init__.py
  2. +26 −0 src/node/ext/zodb/__init__.txt
@@ -5,6 +5,7 @@
default,
extend,
finalize,
+ plumb,
)
from odict.pyodict import (
_odict,
@@ -123,6 +124,11 @@ def __setattr__(self, name, value):
@extend
def __call__(self):
transaction.commit()
+
+ @plumb
+ def __setitem__(_next, self, key, value):
+ _next(self, key, value)
+ self.storage._p_changed = 1
class PodictStorage(ZODBPart, Storage):
@@ -328,6 +328,32 @@ OOBTNode. Based on OOBTree as storage::
>>> oobtnode.attrs.bar
<OOBTNode object 'bar' at ...>
+
+ >>> oobtnode.attrs.foo = 2
+ >>> oobtnode.attrs.foo
+ 2
+
+ >>> oobtnode.attribute_access_for_attrs = False
+ >>> oobtnode.attrs.storage
+ OOBTodict([('foo', 2), ('bar', <OOBTNode object 'bar' at ...>)])
+
+ >>> oobtnode.attrs._storage
+ OOBTodict([('foo', 2), ('bar', <OOBTNode object 'bar' at ...>)])
+
+ >>> oobtnode.attrs.storage is oobtnode.attrs._storage
+ True
+
+ >>> oobtnode()
+ >>> connection.close()
+ >>> db.close()
+ >>> storage = FileStorage(os.path.join(tempdir, 'Data.fs'))
+ >>> db = DB(storage)
+ >>> connection = db.open()
+ >>> root = connection.root()
+ >>> oobtnode = root['oobtnode']
+ >>> oobtnode.attribute_access_for_attrs = False
+ >>> oobtnode.attrs.storage
+ OOBTodict([('foo', 2), ('bar', <OOBTNode object 'bar' at ...>)])
Fill root with some OOBTNodes and check memory usage::

0 comments on commit bc6ae4d

Please sign in to comment.