--- a/server/python/junius/model.py
+++ b/server/python/junius/model.py
@@ -302,16 +302,18 @@ class DocumentModel(object):
logger.debug("saved multiple docs with result=%(ok)s", result)
ds = []
for dinfo, dattach in zip(result['new_revs'], attachments):
if dattach:
ds.append(self._cb_save_attachments(dinfo, dattach))
return defer.DeferredList(ds)
def _cb_save_attachments(self, saved_doc, attachments):
+ if not attachments:
+ return saved_doc
# Each time we save an attachment the doc gets a new revision number.
# So we need to do them in a chain, passing the result from each to
# the next.
remaining = attachments.copy()
# This is recursive, but that should be OK.
return self._cb_save_next_attachment(saved_doc, remaining)
def _cb_save_next_attachment(self, result, remaining):
@@ -384,15 +386,17 @@ def fab_db(whateva):
db = get_db(couch_name, None)
dbinfo = config.couches[couch_name]
def _create_failed(failure, *args, **kw):
failure.trap(twisted.web.error.Error)
if failure.value.status != '412': # precondition failed.
failure.raiseException()
logger.info("couch database %(name)r already exists", dbinfo)
+ return False
def _created_ok(d):
logger.info("created new database")
+ return True
return db.createDB(dbinfo['name']
).addCallbacks(_created_ok, _create_failed
)