From 0277062693c7e07353f78bae113d557dd48cf1ca Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Fri, 24 Jan 2014 13:17:52 +0000 Subject: [PATCH] Stop ensure_indexes running on a secondaries (#555) --- docs/changelog.rst | 4 ++++ mongoengine/document.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 3d8c3307..0a0d91dd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,10 @@ Changelog ========= +Changes in 0.8.7 +================ +- Stop ensure_indexes running on a secondaries (#555) + Changes in 0.8.6 ================ - Fix django auth import (#531) diff --git a/mongoengine/document.py b/mongoengine/document.py index b47490bd..9a260279 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -549,6 +549,8 @@ class Document(BaseDocument): index_cls = cls._meta.get('index_cls', True) collection = cls._get_collection() + if collection.read_preference > 1: + return # determine if an index which we are creating includes # _cls as its first field; if so, we can avoid creating