allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/2] allura git commit: [#8038] mongo 3 raises error when calling index_information() on non-existant collection/db
Date Tue, 12 Jan 2016 15:37:57 GMT
Repository: allura
Updated Branches:
  refs/heads/db/8038 [created] e0ef8b8ad


[#8038] mongo 3 raises error when calling index_information() on non-existant collection/db


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/f31b4ee2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/f31b4ee2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/f31b4ee2

Branch: refs/heads/db/8038
Commit: f31b4ee2dce874a0074847d8d0d3e2a46b0982c0
Parents: a0f7f3d
Author: Dave Brondsema <dave@brondsema.net>
Authored: Tue Jan 12 09:54:31 2016 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Tue Jan 12 09:54:31 2016 -0500

----------------------------------------------------------------------
 Allura/allura/command/show_models.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f31b4ee2/Allura/allura/command/show_models.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index 917f516..95f362b 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -22,7 +22,7 @@ from itertools import groupby
 
 from paste.deploy.converters import asbool
 from pylons import tmpl_context as c, app_globals as g
-from pymongo.errors import DuplicateKeyError, InvalidDocument
+from pymongo.errors import DuplicateKeyError, InvalidDocument, OperationFailure
 
 from ming.orm import mapper, session, Mapper
 from ming.orm.declarative import MappedClass
@@ -257,7 +257,12 @@ class EnsureIndexCommand(base.Command):
         prev_uindexes = {}
         unique_flag_drop = {}
         unique_flag_add = {}
-        for iname, fields in collection.index_information().iteritems():
+        try:
+            existing_indexes = collection.index_information().iteritems()
+        except OperationFailure:
+            # exception is raised if db or collection doesn't exist yet
+            existing_indexes = {}
+        for iname, fields in existing_indexes:
             if iname == '_id_':
                 continue
             keys = tuple(fields['key'])


Mime
View raw message