def create_model(self, form): model = Model(self.last_id) self.last_id += 1 form.populate_obj(model) self.created_models.append(model) self.all_models[model.id] = model return True
def update_model(self, form, model): try: form.populate_obj(model) self.on_model_change(form, model) model.save() # For peewee have to save inline forms after model was saved save_inline(form, model) except Exception, ex: flash(gettext('Failed to update model. %(error)s', error=str(ex)), 'error') logging.exception('Failed to update model') return False
def create_model(self, form): try: model = self.model() form.populate_obj(model) model.save() # For peewee have to save inline forms after model was saved save_inline(form, model) return True except Exception, ex: flash(gettext('Failed to create model. %(error)s', error=str(ex)), 'error') return False
def update_model(self, form, model): try: form.populate_obj(model) model.save() # For peewee have to save inline forms after model was saved save_inline(form, model) self.on_model_change(form, model) return True except Exception, ex: flash(gettext("Failed to update model. %(error)s", error=str(ex)), "error") return False
def update_model(self, form, model): print "---update_model called" try: form.populate_obj(model) print form.data # append set__ to all keys set_data = dict(map(lambda (key, value): ("set__"+str(key), value), form.data.items())) print set_data model.save(validate=False) # For peewee have to save inline forms after model was saved save_inline(form, model) return True except Exception, ex: flash(gettext('Failed to update model. %(error)s', error=str(ex)), 'error') return False
def create_model(self, form): try: model = self.model() form.populate_obj(model) self.on_model_change(form, model) model.save() # For peewee have to save inline forms after model was saved save_inline(form, model) except Exception as ex: flash(gettext('Failed to create model. %(error)s', error=str(ex)), 'error') logging.exception('Failed to create model') return False else: self.after_model_change(form, model, True) return True
def update_model(self, form, model): try: form.populate_obj(model) self._on_model_change(form, model, False) model.save() # For peewee have to save inline forms after model was saved save_inline(form, model) except Exception as ex: if self._debug: raise flash(gettext("Failed to update model. %(error)s", error=str(ex)), "error") logging.exception("Failed to update model") return False else: self.after_model_change(form, model, False) return True
def update_model(self, form, model): form.populate_obj(model) self.updated_models.append(model) return True