labpack/databases/google/datastore.py
def update(self, record):

        ''' a method to update an existing record 
        
        :param record: dictionary with record fields 
        :return: dictionary with record fields 
        '''

        title = '%s.update' % self.__class__.__name__

        # validate inputs
        details = self.model.validate(record, object_title='%s(record={...})' % title)

        # validate id
        if not 'id' in details.keys():
            raise ValueError('%s(record) must contain an id field.' % title)
        elif not details['id']:
            raise ValueError('%s(record) id field must not be empty.' % title)

        # prepare record for updating
        fields = self._prepare_record(details)
        uid = fields['id']
        del fields['id']

        # prepare entity
        # https://cloud.google.com/datastore/docs/concepts/entities#updating_an_entity
        key = self.client.key(self.kind, uid)
        exclusions = set(fields.keys()) - self.store_indices
        kwargs = {'key': key}
        if exclusions:
            kwargs['exclude_from_indexes'] = list(exclusions)
        entity = datastore.Entity(**kwargs)
        entity.update(fields)

        # update database
        self.client.put(entity)

        return details
 a method to update an existing record 
        
        :param record: dictionary with record fields 
        :return: dictionary with record fields 
        
a method to update an existing record
a method to update an existing record
def update(self, record):
        title = '%s.update' % self.__class__.__name__
        details = self.model.validate(record, object_title='%s(record={...})' % title)
        if not 'id' in details.keys():
            raise ValueError('%s(record) must contain an id field.' % title)
        elif not details['id']:
            raise ValueError('%s(record) id field must not be empty.' % title)
        fields = self._prepare_record(details)
        uid = fields['id']
        del fields['id']
        key = self.client.key(self.kind, uid)
        exclusions = set(fields.keys()) - self.store_indices
        kwargs = {'key': key}
        if exclusions:
            kwargs['exclude_from_indexes'] = list(exclusions)
        entity = datastore.Entity(**kwargs)
        entity.update(fields)
        self.client.put(entity)
        return details
def update ( self , record ) : title = '%s.update' % self . __class__ . __name__ details = self . model . validate ( record , object_title = '%s(record={...})' % title ) if not 'id' in details . keys ( ) : raise ValueError ( '%s(record) must contain an id field.' % title ) elif not details [ 'id' ] : raise ValueError ( '%s(record) id field must not be empty.' % title ) fields = self . _prepare_record ( details ) uid = fields [ 'id' ] del fields [ 'id' ] key = self . client . key ( self . kind , uid ) exclusions = set ( fields . keys ( ) ) - self . store_indices kwargs = { 'key' : key } if exclusions : kwargs [ 'exclude_from_indexes' ] = list ( exclusions ) entity = datastore . Entity ( ** kwargs ) entity . update ( fields ) self . client . put ( entity ) return details
a method to update an existing record
a method to update an existing record
''' a method to update an existing record 
        
        :param record: dictionary with record fields 
        :return: dictionary with record fields 
        ''' # validate inputs # validate id # prepare record for updating # prepare entity # https://cloud.google.com/datastore/docs/concepts/entities#updating_an_entity # update database
dictionary with record fields
dictionary with record fields
self
record
dictionary with record fields
dictionary with record fields