summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2/src/authorization
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2016-02-28 22:30:22 -0800
committerSteve Piercy <web@stevepiercy.com>2016-02-28 22:30:22 -0800
commit3e30040da7c2d5c38b330727b48d9f6b852956d9 (patch)
treeb413abc85048bd7a3697b8844b0f250b8bc66bb9 /docs/tutorials/wiki2/src/authorization
parentde3062576ce5aa8b2e854626a48e3f5c46b29cb7 (diff)
downloadpyramid-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/authorization')
-rw-r--r--docs/tutorials/wiki2/src/authorization/tutorial/routes.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/routes.py b/docs/tutorials/wiki2/src/authorization/tutorial/routes.py
index c7c3a2120..f0a8b7f96 100644
--- a/docs/tutorials/wiki2/src/authorization/tutorial/routes.py
+++ b/docs/tutorials/wiki2/src/authorization/tutorial/routes.py
@@ -1,4 +1,7 @@
-from pyramid.httpexceptions import HTTPNotFound
+from pyramid.httpexceptions import (
+ HTTPNotFound,
+ HTTPFound,
+)
from pyramid.security import (
Allow,
Everyone,
@@ -19,6 +22,9 @@ def includeme(config):
def new_page_factory(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)
+ raise HTTPFound(location=next_url)
return NewPage(pagename)
class NewPage(object):