removed deprecated warning for 'update' method
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
from mongoengine.common import _import_class
|
||||
from mongoengine.connection import DEFAULT_CONNECTION_NAME, get_db
|
||||
from pymongo.write_concern import WriteConcern
|
||||
from contextlib import contextmanager
|
||||
|
||||
|
||||
__all__ = ('switch_db', 'switch_collection', 'no_dereference',
|
||||
'no_sub_classes', 'query_counter')
|
||||
'no_sub_classes', 'query_counter', 'set_write_concern')
|
||||
|
||||
|
||||
class switch_db(object):
|
||||
@@ -215,3 +217,10 @@ class query_counter(object):
|
||||
count = self.db.system.profile.find(ignore_query).count() - self.counter
|
||||
self.counter += 1
|
||||
return count
|
||||
|
||||
|
||||
@contextmanager
|
||||
def set_write_concern(collection, write_concerns):
|
||||
yield collection.with_options(write_concern=WriteConcern(
|
||||
**dict(collection.write_concern.document.items()),
|
||||
**write_concerns))
|
||||
|
||||
Reference in New Issue
Block a user