Skip to content

Commit a00cc73

Browse files
committed
Replace mongodb operation insert with inster_one
Fixes deprecation warning: """ DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead. """ Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent e29f899 commit a00cc73

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/saml2/mdbcache.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ def set(self, subject_id, entity_id, info, timestamp=0):
119119
time.struct_time):
120120
timestamp = time.strftime(TIME_FORMAT, timestamp)
121121

122-
doc = {"subject_id": subject_id,
123-
"entity_id": entity_id,
124-
"info": info,
125-
"timestamp": timestamp}
126-
127-
_ = self._cache.insert(doc)
122+
doc = {
123+
"subject_id": subject_id,
124+
"entity_id": entity_id,
125+
"info": info,
126+
"timestamp": timestamp,
127+
}
128+
129+
_ = self._cache.insert_one(doc)
128130

129131
def reset(self, subject_id, entity_id):
130132
""" Scrap the assertions received from a IdP or an AA about a special

src/saml2/mongo_store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ def store_assertion(self, assertion, to_sign):
5454
"name_id_key": nkey,
5555
"assertion_id": assertion.id,
5656
"assertion": to_dict(assertion, MMODS, True),
57-
"to_sign": to_sign
57+
"to_sign": to_sign,
5858
}
5959

60-
_ = self.assertion.insert(doc)
60+
_ = self.assertion.insert_one(doc)
6161

6262
def get_assertion(self, cid):
6363
res = []
@@ -215,7 +215,7 @@ def store(self, value, **kwargs):
215215
# Add timestamp to all documents to allow external garbage collecting
216216
if "created_at" not in doc:
217217
doc["created_at"] = datetime.datetime.utcnow()
218-
_ = self.db.insert(doc)
218+
_ = self.db.insert_one(doc)
219219

220220
def get(self, value=None, **kwargs):
221221
if value is not None:

0 commit comments

Comments
 (0)