[Checkins] SVN: zope.fssync/trunk/ land the achapman-error-collection branch:
Fred Drake
cvs-admin at zope.org
Thu Mar 15 15:32:55 UTC 2012
Log message for revision 124615:
land the achapman-error-collection branch:
collect multiple errors from the server side to report
them all, as overhead cost is high (a human waiting for the response)
Changed:
U zope.fssync/trunk/CHANGES.txt
U zope.fssync/trunk/setup.py
U zope.fssync/trunk/src/zope/fssync/README.txt
U zope.fssync/trunk/src/zope/fssync/task.py
-=-
Modified: zope.fssync/trunk/CHANGES.txt
===================================================================
--- zope.fssync/trunk/CHANGES.txt 2012-03-15 15:24:09 UTC (rev 124614)
+++ zope.fssync/trunk/CHANGES.txt 2012-03-15 15:32:52 UTC (rev 124615)
@@ -1,10 +1,11 @@
Changes
=======
-3.5.3 (unreleased)
+3.6.0 (unreleased)
------------------
-- ...
+- Commit task will collect errors and send them all back rather
+ than stopping on the first error encountered.
3.5.2 (2010-10-18)
Modified: zope.fssync/trunk/setup.py
===================================================================
--- zope.fssync/trunk/setup.py 2012-03-15 15:24:09 UTC (rev 124614)
+++ zope.fssync/trunk/setup.py 2012-03-15 15:32:52 UTC (rev 124615)
@@ -24,7 +24,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.fssync',
- version = '3.5.3dev',
+ version = '3.6.0dev',
url='http://pypi.python.org/pypi/zope.fssync',
license='ZPL 2.1',
description="Filesystem synchronization utility for Zope 3.",
Modified: zope.fssync/trunk/src/zope/fssync/README.txt
===================================================================
--- zope.fssync/trunk/src/zope/fssync/README.txt 2012-03-15 15:24:09 UTC (rev 124614)
+++ zope.fssync/trunk/src/zope/fssync/README.txt 2012-03-15 15:32:52 UTC (rev 124615)
@@ -809,3 +809,33 @@
'annotation a'
>>> [x for x in interface.directlyProvidedBy(result)]
[<InterfaceClass zope.fssync.doctest.IMarkerInterface>]
+
+If we encounter an error, or multiple errors, while commiting we'll
+see them in the traceback.
+
+ >>> def bad_sync(container, key, fspath, add_callback):
+ ... raise ValueError('1','2','3')
+
+ >>> target = {}
+ >>> commit = task.Commit(synchronizer.getSynchronizer, snarf)
+ >>> old_sync_new = commit.synchNew
+ >>> commit.synchNew = bad_sync
+ >>> commit.perform(target, 'root', 'test')
+ Traceback (most recent call last):
+ ...
+ Exception: 1,2,3
+
+Notice that if we encounter multiple exceptions we print them all
+out at the end.
+
+ >>> old_sync_old = commit.synchOld
+ >>> commit.synchOld = bad_sync
+ >>> commit.perform(target, 'root', 'test')
+ Traceback (most recent call last):
+ ...
+ Exceptions:
+ 1,2,3
+ 1,2,3
+
+ >>> commit.synchNew = old_sync_new
+ >>> commit.synchOld = old_sync_old
Modified: zope.fssync/trunk/src/zope/fssync/task.py
===================================================================
--- zope.fssync/trunk/src/zope/fssync/task.py 2012-03-15 15:24:09 UTC (rev 124614)
+++ zope.fssync/trunk/src/zope/fssync/task.py 2012-03-15 15:32:52 UTC (rev 124615)
@@ -162,6 +162,11 @@
self.dumpMetadata(epath, entries)
+class Exceptions(Exception):
+ # We use this to pluralize "Exception".
+ pass
+
+
class Commit(SyncTask):
"""Commit changes from a repository to the object database.
@@ -177,12 +182,20 @@
def __init__(self, getSynchronizer, repository):
super(Commit, self).__init__(getSynchronizer, repository)
self.metadata = self.repository.getMetadata()
+ self.errors = []
def perform(self, container, name, fspath):
callbacks = []
add_callback = callbacks.append
self.synchronize(container, name, fspath, add_callback)
+ # check for errors
+ if self.errors:
+ if len(self.errors) == 1:
+ raise Exception(self.errors[0])
+ else:
+ raise Exceptions("\n ".join([""] + self.errors))
+
# process callbacks
passes = 0
callbacks = [cb for cb in callbacks if cb is not None]
@@ -219,9 +232,18 @@
try:
traverseKey(container, key)
except:
- self.synchNew(container, key, fspath, add_callback)
+ try:
+ self.synchNew(container, key, fspath, add_callback)
+ except Exception, e:
+ self.errors.append(','.join(e.args))
+ return
else:
- modified = self.synchOld(container, key, fspath, add_callback)
+ try:
+ modified = self.synchOld(container, key, fspath,
+ add_callback)
+ except Exception, e:
+ self.errors.append(','.join(e.args))
+ return
if modified:
modifications.append(modified)
# Now update extra and annotations
More information about the checkins
mailing list