def POST(self): i = web.input(action='', sitename='', siteurl='') web.header('Content-Type', 'application/json') if i.action == 'add': return json.dumps(models.insert(i.sitename, i.siteurl)) elif i.action == 'remove': return json.dumps(models.remove(i.sitename)) else: return json.dumps('none')
def id(id): book = Book.query.filter_by(id=id).first() #id = book.id form = SelectForm(title=book.title, author=book.author, quantity=book.quantity, price=book.price) if form.validate_on_submit(): if form.delete.data: models.remove(id=id) return home() elif form.update.data: title = form.title.data author = form.author.data quantity = form.quantity.data price = form.price.data models.update(id, title, author, quantity, price) return home() return render_template("id.html", form=form)
def trim(): """remove unnecessary data from blog collection """ # these posts are unpublished, so remove them from blog.posts for postid in ('3139542', '3177535', '3179264', '3180481', '3186614', '3197396', '3200131'): models.remove(postid)