summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2/src/authorization
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2016-02-29 10:04:57 -0600
committerMichael Merickel <michael@merickel.org>2016-02-29 10:04:57 -0600
commit0c185a3f7bd717845b7e5a00bd0d7a267be582b6 (patch)
tree610999c8fe6579c0771b9e64809f55fc9c96e9a9 /docs/tutorials/wiki2/src/authorization
parent20eac53d0df1687be897677dfc0dd0405271faef (diff)
parentae5cccc2bb5e749effc34f624e0abbb149fc389f (diff)
downloadpyramid-0c185a3f7bd717845b7e5a00bd0d7a267be582b6.tar.gz
pyramid-0c185a3f7bd717845b7e5a00bd0d7a267be582b6.tar.bz2
pyramid-0c185a3f7bd717845b7e5a00bd0d7a267be582b6.zip
Merge pull request #2385 from stevepiercy/feature/alchemy-scaffold-update
redirect to edit page when user attempts to add page that already exists
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):