From f9d333efb86112bae3e145913b9caa3c10d06d29 Mon Sep 17 00:00:00 2001
From: Gunnar Schaefer <gsfr@stanford.edu>
Date: Tue, 1 Sep 2015 17:42:01 -0700
Subject: [PATCH] adapt insert_one calls to new return value

---
 api/acquisitions.py | 2 +-
 api/collections.py  | 2 +-
 api/containers.py   | 2 +-
 api/projects.py     | 2 +-
 api/sessions.py     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/api/acquisitions.py b/api/acquisitions.py
index 32bfdc76..17921948 100644
--- a/api/acquisitions.py
+++ b/api/acquisitions.py
@@ -95,7 +95,7 @@ class Acquisitions(containers.ContainerList):
         json_body['files'] = []
         if 'timestamp' in json_body:
             json_body['timestamp'] = util.parse_timestamp(json_body['timestamp'])
-        return {'_id': str(self.dbc.insert_one(json_body))}
+        return {'_id': str(self.dbc.insert_one(json_body).inserted_id)}
 
     def get(self, sid):
         """Return the list of Session Acquisitions."""
diff --git a/api/collections.py b/api/collections.py
index 63728754..ab7acb2e 100644
--- a/api/collections.py
+++ b/api/collections.py
@@ -199,7 +199,7 @@ class Collections(containers.ContainerList):
         json_body['curator'] = self.uid
         json_body['timestamp'] = datetime.datetime.utcnow()
         json_body['permissions'] = [{'_id': self.uid, 'access': 'admin'}]
-        return {'_id': str(self.dbc.insert_one(json_body))}
+        return {'_id': str(self.dbc.insert_one(json_body).inserted_id)}
 
     def get(self):
         """Return the list of Collections."""
diff --git a/api/containers.py b/api/containers.py
index fbf04463..7d3847d4 100644
--- a/api/containers.py
+++ b/api/containers.py
@@ -244,7 +244,7 @@ class Container(base.RequestHandler):
         filepath = os.path.join(self.app.config['data_path'], str(_id)[-3:] + '/' + str(_id), filename)
         if self.request.GET.get('ticket') == '':    # request for download ticket
             ticket = util.download_ticket(self.request.client_addr, 'file', _id, filename, fileinfo['filesize'])
-            return {'ticket': self.app.db.downloads.insert_one(ticket)}
+            return {'ticket': self.app.db.downloads.insert_one(ticket).inserted_id}
         else:                                       # authenticated or ticketed (unauthenticated) download
             zip_member = self.request.GET.get('member')
             if self.request.GET.get('info', '').lower() in ('1', 'true'):
diff --git a/api/projects.py b/api/projects.py
index e36ae85e..b745018c 100644
--- a/api/projects.py
+++ b/api/projects.py
@@ -110,7 +110,7 @@ class Projects(containers.ContainerList):
         json_body['public'] = json_body.get('public', False)
         json_body['files'] = []
         json_body['timestamp'] = datetime.datetime.utcnow()
-        return {'_id': str(self.dbc.insert_one(json_body))}
+        return {'_id': str(self.dbc.insert_one(json_body).inserted_id)}
 
     def get(self, uid=None, gid=None):
         """Return the User's list of Projects."""
diff --git a/api/sessions.py b/api/sessions.py
index a3462a38..8d4fffc6 100644
--- a/api/sessions.py
+++ b/api/sessions.py
@@ -100,7 +100,7 @@ class Sessions(containers.ContainerList):
         json_body['files'] = []
         if 'timestamp' in json_body:
             json_body['timestamp'] = util.parse_timestamp(json_body['timestamp'])
-        return {'_id': str(self.dbc.insert_one(json_body))}
+        return {'_id': str(self.dbc.insert_one(json_body).inserted_id)}
 
     def get(self, pid=None, gid=None):
         """Return the list of project or group sessions."""
-- 
GitLab