Beispiel #1
0
 def import_data(self, **data):
     """
     updates/creates entities
     :parm data(dict): contains all the fields that will be updated
      for the entity as keys
     return: Entity object crosspoding to given id
     """
     for key, value in data.items():
         try:
             setattr(self, key, value)
         except KeyError as e:
             app.logger.error('Invalid {0}: missing \
                 ' + e.args[0])
             self.errors[key] = FORM_EMPTY_FIELD.format(key)
             raise ValidationError(('Invalid {0}: missing \
                 ' + e.args[0]).format(self.__tablename__))
     return self