summaryrefslogtreecommitdiff
path: root/docs/quick_tour/view_classes/views.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-08-20 10:15:49 -0400
committerChris McDonough <chrism@plope.com>2013-08-20 10:15:49 -0400
commit70dbf740b5b3500edbcc4b2dff376f43e6250d79 (patch)
tree4bd5335585247a0cc8154149a6c6765fabf10075 /docs/quick_tour/view_classes/views.py
parent0d37d81949bc82de1bd9c1193f282909f9576c3a (diff)
parente64e71523d70261b551ba41f13f389ebf1324f1b (diff)
downloadpyramid-70dbf740b5b3500edbcc4b2dff376f43e6250d79.tar.gz
pyramid-70dbf740b5b3500edbcc4b2dff376f43e6250d79.tar.bz2
pyramid-70dbf740b5b3500edbcc4b2dff376f43e6250d79.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