def put(self, id):
        """
        Update a resource by bson ObjectId

        :returns: json string representation
        :rtype: JSON
        """
        try:
            #Async update flow
            object_ = json_util.loads(self.request.body)

            toa = self.request.headers.get("Caesium-TOA", None)

            obj_check = yield self.client.find_one_by_id(id)
            if not obj_check:
                self.raise_error(404, "Resource not found: %s" % id)
                self.finish()
                return

            if toa:

                stack = AsyncSchedulableDocumentRevisionStack(self.client.collection_name, self.settings, master_id=id)
                revision_id = yield stack.push(object_, int(toa), meta=self._get_meta_data())

                if isinstance(revision_id, str):
                    self.set_header("Caesium-TOA", toa)

                    #We add the id of the original request, because we don't want to infer this
                    #On the client side, as the state of the client code could change easily
                    #We want this request to return with the originating ID as well.
                    object_["id"] = id
                    self.return_resource(object_)
                else:
                    self.raise_error(404, "Revision not scheduled for object: %s" % id)

            else:
                if object_.get("_id"):
                    del object_["_id"]

                response = yield self.client.update(id, object_)

                if response.get("updatedExisting"):
                    object_ = yield self.client.find_one_by_id(id)
                    self.return_resource(object_)
                else:
                    self.raise_error(404, "Resource not found: %s" % id)

        except ValidationError as vex:
            self.logger.error("%s validation error" % self.object_name, vex)
            self.raise_error(400, "Your %s cannot be updated because it is missing required fields, see docs" % self.object_name)
        except ValueError as ex:
            self.raise_error(400, "Invalid JSON Body, check formatting. %s" % ex[0])
        except InvalidId as ex:
            self.raise_error(message="Your ID is malformed: %s" % id)
        except Exception as ex:
            self.logger.error(ex)
            self.raise_error()
def put ( self , id ) : try : object_ = json_util . loads ( self . request . body ) toa = self . request . headers . get ( "Caesium-TOA" , None ) obj_check = yield self . client . find_one_by_id ( id ) if not obj_check : self . raise_error ( 404 , "Resource not found: %s" % id ) self . finish ( ) return if toa : stack = AsyncSchedulableDocumentRevisionStack ( self . client . collection_name , self . settings , master_id = id ) revision_id = yield stack . push ( object_ , int ( toa ) , meta = self . _get_meta_data ( ) ) if isinstance ( revision_id , str ) : self . set_header ( "Caesium-TOA" , toa ) object_ [ "id" ] = id self . return_resource ( object_ ) else : self . raise_error ( 404 , "Revision not scheduled for object: %s" % id ) else : if object_ . get ( "_id" ) : del object_ [ "_id" ] response = yield self . client . update ( id , object_ ) if response . get ( "updatedExisting" ) : object_ = yield self . client . find_one_by_id ( id ) self . return_resource ( object_ ) else : self . raise_error ( 404 , "Resource not found: %s" % id ) except ValidationError as vex : self . logger . error ( "%s validation error" % self . object_name , vex ) self . raise_error ( 400 , "Your %s cannot be updated because it is missing required fields, see docs" % self . object_name ) except ValueError as ex : self . raise_error ( 400 , "Invalid JSON Body, check formatting. %s" % ex [ 0 ] ) except InvalidId as ex : self . raise_error ( message = "Your ID is malformed: %s" % id ) except Exception as ex : self . logger . error ( ex ) self . raise_error ( )
Update a resource by bson ObjectId

        :returns: json string representation
        :rtype: JSON