blog/app/models/__init__.py
def update(self, verbose=True):
        """ Uses flask.request.json values to update an initialized object.
        Keys have to be in the self.data_model to be supported. """
        params = flask.request.json
        for key, value in params.items():

            if value == 'None':
                value = None

            if key == 'updated_on':
                value = datetime.now()

            if key in self.data_model.keys():

                # unfuck javascript-style date strings
                if self.data_model[key] == datetime:
                    if isinstance(value, datetime):
                        pass
                    elif isinstance(value, dict):
                        value = datetime.fromtimestamp(value['$date'] / 1000.0)
                    else:
                        try:
                            value = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.000Z')
                        except ValueError:
                            try:
                                value = datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
                            except Exception as e:
                                raise
                        except TypeError as e:
                            err_msg = "Incoming attribute '%s' must be datetime!"
                            self.logger.error(err_msg % key)
                            self.logger.error("Got value '%s' instead..." % value)
                            raise Exception(err_msg % key)

                # set the self.attribute values
                setattr(self, key, value)

        self.save(verbose)
 Uses flask.request.json values to update an initialized object.
        Keys have to be in the self.data_model to be supported. 
Uses flask.request.json values to update an initialized object.
Keys have to be in the self.data_model to be supported.
Uses flask . request . json values to update an initialized object . Keys have to be in the self . data_model to be supported .
def update(self, verbose=True):
        params = flask.request.json
        for key, value in params.items():
            if value == 'None':
                value = None
            if key == 'updated_on':
                value = datetime.now()
            if key in self.data_model.keys():
                if self.data_model[key] == datetime:
                    if isinstance(value, datetime):
                        pass
                    elif isinstance(value, dict):
                        value = datetime.fromtimestamp(value['$date'] / 1000.0)
                    else:
                        try:
                            value = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.000Z')
                        except ValueError:
                            try:
                                value = datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
                            except Exception as e:
                                raise
                        except TypeError as e:
                            err_msg = "Incoming attribute '%s' must be datetime!"
                            self.logger.error(err_msg % key)
                            self.logger.error("Got value '%s' instead..." % value)
                            raise Exception(err_msg % key)
                setattr(self, key, value)
        self.save(verbose)
def update ( self , verbose = True ) : params = flask . request . json for key , value in params . items ( ) : if value == 'None' : value = None if key == 'updated_on' : value = datetime . now ( ) if key in self . data_model . keys ( ) : if self . data_model [ key ] == datetime : if isinstance ( value , datetime ) : pass elif isinstance ( value , dict ) : value = datetime . fromtimestamp ( value [ '$date' ] / 1000.0 ) else : try : value = datetime . strptime ( value , '%Y-%m-%dT%H:%M:%S.000Z' ) except ValueError : try : value = datetime . strptime ( value , '%Y-%m-%d %H:%M:%S' ) except Exception as e : raise except TypeError as e : err_msg = "Incoming attribute '%s' must be datetime!" self . logger . error ( err_msg % key ) self . logger . error ( "Got value '%s' instead..." % value ) raise Exception ( err_msg % key ) setattr ( self , key , value ) self . save ( verbose )
Uses flask.request.json values to update an initialized object.
Uses flask . request . json values to update an initialized object .
""" Uses flask.request.json values to update an initialized object.
        Keys have to be in the self.data_model to be supported. """ # unfuck javascript-style date strings # set the self.attribute values
self
verbose