def update_wiki(): '''Update a wiki page.''' # If the path changed, then this is now a new page. if request.form['original_page_path'] != request.form['page_path']: return make_wiki() else: # Because the path is the same as the original, then it must be valid # because it is a pre-existing page. page_path = request.form['page_path'] page = WikiPage(page_path) if not page.store(request.form['wiki_content']): # Storing would fail if something unrecoverable happened. abort(500) app.search_engine.update_wiki(page_path, request.form['wiki_content']) return redirect(url_for('wiki', page_path=page_path))
def make_wiki(): '''Make the wiki page.''' page_path = request.form['page_path'] content = request.form['wiki_content'] try: validate_page_path(page_path) page = WikiPage(page_path) # Proceed if the wiki does not exist. if not page.exists: if not page.store(content): # Storing would fail if something unrecoverable happened. abort(500) app.search_engine.add_wiki(page_path, content) return redirect(url_for('wiki', page_path=page_path)) else: flash('That wiki name already exists. Please choose another.') return create(page_path, request.form['wiki_content']) except ValidationError as verror: flash(verror.message) return create(page_path, request.form['wiki_content'])