Browse Source

Work with pymongo 3.0

pymongo 3.0 renamed mongos_enum to read_pref_mode_from_name which
was causing the unit tests to fail.

Change-Id: Iaa7fd7221c2e6c865633ef342e6b83304a1de655
Closes-Bug: 1441393
tags/8.0.0a0
Brant Knudson 5 years ago
parent
commit
7c3fe6acae
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      keystone/common/cache/backends/mongo.py

+ 6
- 2
keystone/common/cache/backends/mongo.py View File

@@ -360,8 +360,12 @@ class MongoApi(object):

self._assign_data_mainpulator()
if self.read_preference:
self.read_preference = pymongo.read_preferences.mongos_enum(
self.read_preference)
# pymongo 3.0 renamed mongos_enum to read_pref_mode_from_name
f = getattr(pymongo.read_preferences,
'read_pref_mode_from_name', None)
if not f:
f = pymongo.read_preferences.mongos_enum
self.read_preference = f(self.read_preference)
coll.read_preference = self.read_preference
if self.w > -1:
coll.write_concern['w'] = self.w


Loading…
Cancel
Save