allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject allura git commit: [#8109] avoid some GridFS index creation
Date Thu, 28 Jul 2016 20:24:09 GMT
Repository: allura
Updated Branches:
  refs/heads/db/8109 [created] 8def1448b


[#8109] avoid some GridFS index creation


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

Branch: refs/heads/db/8109
Commit: 8def1448b16e99518120c7509634111113755dc4
Parents: 1bef5be
Author: Dave Brondsema <dave@brondsema.net>
Authored: Thu Jul 28 16:15:47 2016 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Thu Jul 28 16:15:47 2016 -0400

----------------------------------------------------------------------
 Allura/allura/model/filesystem.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8def1448/Allura/allura/model/filesystem.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/filesystem.py b/Allura/allura/model/filesystem.py
index af1dea1..5b747b2 100644
--- a/Allura/allura/model/filesystem.py
+++ b/Allura/allura/model/filesystem.py
@@ -59,9 +59,16 @@ class File(MappedClass):
 
     @classmethod
     def _fs(cls):
-        return GridFS(
-            session(cls).impl.db,
-            cls._root_collection())
+        gridfs_args = (session(cls).impl.db, cls._root_collection())
+        try:
+            # for some pymongo 2.x versions the _connect option is available to avoid index
creation on every usage
+            # (it'll still create indexes on delete & write)
+            gridfs = GridFS(*gridfs_args, _connect=False)
+        except TypeError:  # (unexpected keyword argument)
+            # pymongo 3.0 removes the _connect arg
+            # pymongo 3.1 makes index creation only happen on the very first write
+            gridfs = GridFS(*gridfs_args)
+        return gridfs
 
     @classmethod
     def _root_collection(cls):


Mime
View raw message