diff options
| author | Steve Piercy <web@stevepiercy.com> | 2016-02-28 22:30:22 -0800 |
|---|---|---|
| committer | Steve Piercy <web@stevepiercy.com> | 2016-02-28 22:30:22 -0800 |
| commit | 3e30040da7c2d5c38b330727b48d9f6b852956d9 (patch) | |
| tree | b413abc85048bd7a3697b8844b0f250b8bc66bb9 /docs/tutorials/wiki2/src/views | |
| parent | de3062576ce5aa8b2e854626a48e3f5c46b29cb7 (diff) | |
| download | pyramid-3e30040da7c2d5c38b330727b48d9f6b852956d9.tar.gz pyramid-3e30040da7c2d5c38b330727b48d9f6b852956d9.tar.bz2 pyramid-3e30040da7c2d5c38b330727b48d9f6b852956d9.zip | |
redirect to edit page when user attempts to add page that already exists
- update src/*/views/default.py
- update src/*/routes.py
- write new test
- revise docs, double-checking line counts and highlighting
Diffstat (limited to 'docs/tutorials/wiki2/src/views')
| -rw-r--r-- | docs/tutorials/wiki2/src/views/tutorial/views/default.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/docs/tutorials/wiki2/src/views/tutorial/views/default.py b/docs/tutorials/wiki2/src/views/tutorial/views/default.py index c1d402f6a..bb6300b75 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/views/default.py +++ b/docs/tutorials/wiki2/src/views/tutorial/views/default.py @@ -58,6 +58,9 @@ def edit_page(request): @view_config(route_name='add_page', renderer='../templates/edit.jinja2') def add_page(request): pagename = request.matchdict['pagename'] + if request.dbsession.query(Page).filter_by(name=pagename).count() > 0: + next_url = request.route_url('edit_page', pagename=pagename) + return HTTPFound(location=next_url) if 'form.submitted' in request.params: body = request.params['body'] page = Page(name=pagename, data=body) |
