You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2016/07/28 20:24:09 UTC

allura git commit: [#8109] avoid some GridFS index creation

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 <da...@brondsema.net>
Authored: Thu Jul 28 16:15:47 2016 -0400
Committer: Dave Brondsema <da...@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):