summaryrefslogtreecommitdiff
path: root/docs/quick_tour/view_classes/views.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-08-15 18:40:27 +0200
committerChris McDonough <chrism@plope.com>2013-08-15 18:40:27 +0200
commit5aab1e9c2aebbbb0e955a34067db9a196d430a0c (patch)
tree727028ad4eeb596c291d0f96fbc9bb520ec971fd /docs/quick_tour/view_classes/views.py
parentb210ce350a3856166376f63a32725cc1516ba294 (diff)
parent7319ab677216063581e47a231fd70b8b55a19466 (diff)
downloadpyramid-5aab1e9c2aebbbb0e955a34067db9a196d430a0c.tar.gz
pyramid-5aab1e9c2aebbbb0e955a34067db9a196d430a0c.tar.bz2
pyramid-5aab1e9c2aebbbb0e955a34067db9a196d430a0c.zip
Merge branch 'master' of github.com:Pylons/pyramid
Diffstat (limited to 'docs/quick_tour/view_classes/views.py')
-rw-r--r--docs/quick_tour/view_classes/views.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/quick_tour/view_classes/views.py b/docs/quick_tour/view_classes/views.py
new file mode 100644
index 000000000..62556142e
--- /dev/null
+++ b/docs/quick_tour/view_classes/views.py
@@ -0,0 +1,32 @@
+from pyramid.view import (
+ view_config,
+ view_defaults
+ )
+
+
+# Start View 1
+# One route, at /howdy/amy, so don't repeat on each @view_config
+@view_defaults(route_name='hello')
+class HelloWorldViews:
+ def __init__(self, request):
+ self.request = request
+ # Our templates can now say {{ view.name }}
+ self.name = request.matchdict['name']
+
+ # Retrieving /howdy/amy the first time
+ @view_config(renderer='hello.jinja2')
+ def hello_view(self):
+ return dict()
+
+ # Posting to /howdy/amy via the "Edit" submit button
+ @view_config(request_param='form.edit', renderer='edit.jinja2')
+ def edit_view(self):
+ print('Edited')
+ return dict()
+
+ # Posting to /howdy/amy via the "Delete" submit button
+ @view_config(request_param='form.delete', renderer='delete.jinja2')
+ def delete_view(self):
+ print('Deleted')
+ return dict()
+ # End View 1 \ No newline at end of file