def delete(self): titles = request.POST.getall('title') pages = self.page_q.filter(Page.title.in_(titles)) for page in pages: Session.delete(page) Session.commit() for title in titles: flash('Deleted %s.' %title) redirect_to('pages')
def save(self, title): page = self.page_q.filter_by(title=title).first() if not page: page = Page(title) page.content = escape(request.POST.getone('content')) Session.add(page) Session.commit() flash('Successfully saved %s!' % title) redirect_to('show_page', title=title)
def save(self, title): c.title = title page = self.page_q.filter_by(title=title).first() if not page: page = Page(title=title) # In a real application, you should validate and sanitize # submitted data throughly! escape is a minimal example here page.content = escape(request.POST.getone('content')) Session.add(page) Session.commit() flash('Successfully saved %s!' % title) redirect(url('show_page', title=title))