[Checkins] SVN: z3c.vcsync/trunk/src/z3c/vcsync/ Fix a bug - cannot
just overwrite entries but have to remove them first.
Martijn Faassen
faassen at infrae.com
Tue Jun 26 15:36:28 EDT 2007
Log message for revision 77112:
Fix a bug - cannot just overwrite entries but have to remove them first.
Changed:
U z3c.vcsync/trunk/src/z3c/vcsync/README.txt
U z3c.vcsync/trunk/src/z3c/vcsync/tests.py
U z3c.vcsync/trunk/src/z3c/vcsync/vc.py
-=-
Modified: z3c.vcsync/trunk/src/z3c/vcsync/README.txt
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/README.txt 2007-06-26 18:10:55 UTC (rev 77111)
+++ z3c.vcsync/trunk/src/z3c/vcsync/README.txt 2007-06-26 19:36:28 UTC (rev 77112)
@@ -236,6 +236,7 @@
The ZODB has changed again. Item 'hoi' has changed from an item into
a container::
+ >>> del data['hoi']
>>> data['hoi'] = Container()
We put some things into the container::
@@ -276,6 +277,7 @@
Let's now change the ZODB again and change the ``hoi`` container back
into a file::
+ >>> del data['hoi']
>>> data['hoi'] = Item(payload=16)
>>> checkout.save(data)
Modified: z3c.vcsync/trunk/src/z3c/vcsync/tests.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/tests.py 2007-06-26 18:10:55 UTC (rev 77111)
+++ z3c.vcsync/trunk/src/z3c/vcsync/tests.py 2007-06-26 19:36:28 UTC (rev 77112)
@@ -8,6 +8,7 @@
from zope.interface import implements, Interface
from zope.app.container.interfaces import IContainer
+from zope.exceptions.interfaces import DuplicationError
from z3c.vcsync.interfaces import ISerializer, IVcDump, IVcLoad, IVcFactory, IModified
from z3c.vcsync import vc
@@ -41,8 +42,13 @@
def values(self):
return self._data.values()
+
+ def __contains__(self, name):
+ return name in self.keys()
def __setitem__(self, name, value):
+ if name in self._data:
+ raise DuplicationError
self._data[name] = value
value.__name__ = name
@@ -52,17 +58,6 @@
def __delitem__(self, name):
del self._data[name]
-
-## class ItemModified(grok.Adapter):
-## grok.context(Item)
-## grok.implements(IModified)
-
-## def modified_since(self, dt):
-## return dt is None or self.context._modified is None or self.context._modified > dt
-
-## def update(self):
-## self.context._modified = datetime.now()
-
def setUpZope(test):
pass
Modified: z3c.vcsync/trunk/src/z3c/vcsync/vc.py
===================================================================
--- z3c.vcsync/trunk/src/z3c/vcsync/vc.py 2007-06-26 18:10:55 UTC (rev 77111)
+++ z3c.vcsync/trunk/src/z3c/vcsync/vc.py 2007-06-26 19:36:28 UTC (rev 77112)
@@ -71,6 +71,8 @@
# XXX what if object is already there?
obj = factory(checkout, sub)
# store the newly created object into the container
+ if sub.purebasename in self.context:
+ del self.context[sub.purebasename]
self.context[sub.purebasename] = obj
loaded.append(sub.purebasename)
# remove any objects not there anymore
More information about the Checkins
mailing list