def delete(page_path): '''Delete the wiki page.''' if page_path == 'Home': flash('You sneaky devil. You can\'t delete the main page. ' 'But feel free to edit it.') return redirect(url_for('index')) try: validate_page_path(page_path) page = WikiPage(page_path) if page.exists: if not page.delete(): # Unsuccessful delete. abort(500) app.search_engine.delete_wiki(page_path) else: flash('That wiki doesn\'t exist.') except ValidationError as verror: # The user tried to delete a bogus page straight from the URL. flash(verror.message) return redirect(url_for('index'))