summaryrefslogtreecommitdiff
path: root/docs/getting_started/quick_glance
diff options
context:
space:
mode:
authorPaul Everitt <paul@agendaless.com>2013-08-07 15:34:58 -0400
committerPaul Everitt <paul@agendaless.com>2013-08-07 15:34:58 -0400
commit65d1719fc5ce4ed4e87c45b1e4279c30930b274e (patch)
treef874999cd13ab9637682d5c79945818b393155e7 /docs/getting_started/quick_glance
parent30c51bd60756ab632553319a231e154c582b8cd1 (diff)
downloadpyramid-65d1719fc5ce4ed4e87c45b1e4279c30930b274e.tar.gz
pyramid-65d1719fc5ce4ed4e87c45b1e4279c30930b274e.tar.bz2
pyramid-65d1719fc5ce4ed4e87c45b1e4279c30930b274e.zip
Up through scaffolds.
Diffstat (limited to 'docs/getting_started/quick_glance')
-rw-r--r--docs/getting_started/quick_glance/jinja2/hello_world.jinja22
-rw-r--r--docs/getting_started/quick_glance/json/hello_world.jinja24
-rw-r--r--docs/getting_started/quick_glance/json/hello_world.pt2
-rw-r--r--docs/getting_started/quick_glance/static_assets/hello_world.jinja24
-rw-r--r--docs/getting_started/quick_glance/static_assets/hello_world.pt5
-rw-r--r--docs/getting_started/quick_glance/templating/hello_world.pt1
-rw-r--r--docs/getting_started/quick_glance/view_classes/app.py23
-rw-r--r--docs/getting_started/quick_glance/view_classes/delete.jinja29
-rw-r--r--docs/getting_started/quick_glance/view_classes/edit.jinja29
-rw-r--r--docs/getting_started/quick_glance/view_classes/hello.jinja217
-rw-r--r--docs/getting_started/quick_glance/view_classes/views.py32
11 files changed, 79 insertions, 29 deletions
diff --git a/docs/getting_started/quick_glance/jinja2/hello_world.jinja2 b/docs/getting_started/quick_glance/jinja2/hello_world.jinja2
index 5fc1fc9bf..e177744b5 100644
--- a/docs/getting_started/quick_glance/jinja2/hello_world.jinja2
+++ b/docs/getting_started/quick_glance/jinja2/hello_world.jinja2
@@ -1,6 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>Quick Glance</title>
+ <title>Hello World</title>
</head>
<body>
<h1>Hello {{ name }}!</h1>
diff --git a/docs/getting_started/quick_glance/json/hello_world.jinja2 b/docs/getting_started/quick_glance/json/hello_world.jinja2
index 3d0f28c1f..f6862e618 100644
--- a/docs/getting_started/quick_glance/json/hello_world.jinja2
+++ b/docs/getting_started/quick_glance/json/hello_world.jinja2
@@ -1,8 +1,8 @@
+<!DOCTYPE html>
<html lang="en">
-<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Quick Glance</title>
- <link rel="stylesheet" href="/static/app.css" />
+ <link rel="stylesheet" href="/static/app.css"/>
</head>
<body>
<h1>Hello {{ name }}!</h1>
diff --git a/docs/getting_started/quick_glance/json/hello_world.pt b/docs/getting_started/quick_glance/json/hello_world.pt
index 0cf20d076..711054aa9 100644
--- a/docs/getting_started/quick_glance/json/hello_world.pt
+++ b/docs/getting_started/quick_glance/json/hello_world.pt
@@ -1,5 +1,5 @@
+<!DOCTYPE html>
<html lang="en">
-<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Quick Glance</title>
<!-- Start Link 1 -->
diff --git a/docs/getting_started/quick_glance/static_assets/hello_world.jinja2 b/docs/getting_started/quick_glance/static_assets/hello_world.jinja2
index 3d0f28c1f..f6862e618 100644
--- a/docs/getting_started/quick_glance/static_assets/hello_world.jinja2
+++ b/docs/getting_started/quick_glance/static_assets/hello_world.jinja2
@@ -1,8 +1,8 @@
+<!DOCTYPE html>
<html lang="en">
-<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Quick Glance</title>
- <link rel="stylesheet" href="/static/app.css" />
+ <link rel="stylesheet" href="/static/app.css"/>
</head>
<body>
<h1>Hello {{ name }}!</h1>
diff --git a/docs/getting_started/quick_glance/static_assets/hello_world.pt b/docs/getting_started/quick_glance/static_assets/hello_world.pt
index 0cf20d076..1797146eb 100644
--- a/docs/getting_started/quick_glance/static_assets/hello_world.pt
+++ b/docs/getting_started/quick_glance/static_assets/hello_world.pt
@@ -1,6 +1,5 @@
-<html lang="en">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
+<!DOCTYPE html>
+<html lang="en"><head>
<title>Quick Glance</title>
<!-- Start Link 1 -->
<link rel="stylesheet" href="/static/app.css" />
diff --git a/docs/getting_started/quick_glance/templating/hello_world.pt b/docs/getting_started/quick_glance/templating/hello_world.pt
index 8860df26a..ae14f447d 100644
--- a/docs/getting_started/quick_glance/templating/hello_world.pt
+++ b/docs/getting_started/quick_glance/templating/hello_world.pt
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
<html lang="en">
<head>
<title>Quick Glance</title>
diff --git a/docs/getting_started/quick_glance/view_classes/app.py b/docs/getting_started/quick_glance/view_classes/app.py
index c29311aa5..468c8c29e 100644
--- a/docs/getting_started/quick_glance/view_classes/app.py
+++ b/docs/getting_started/quick_glance/view_classes/app.py
@@ -1,30 +1,13 @@
from wsgiref.simple_server import make_server
-
from pyramid.config import Configurator
-from pyramid.view import view_config
-
-
-class HelloWorldViews:
- def __init__(self, request):
- self.request = request
-
- @view_config(route_name='hello', renderer='app4.jinja2')
- def hello_world(self):
- return dict(name=self.request.matchdict['name'])
-
-
- @view_config(route_name='hello_json', renderer='json')
- def hello_json(self):
- return [1, 2, 3]
-
if __name__ == '__main__':
config = Configurator()
+ # Start Routes 1
config.add_route('hello', '/howdy/{name}')
- config.add_route('hello_json', 'hello.json')
- config.add_static_view(name='static', path='static')
+ # End Routes 1
config.include('pyramid_jinja2')
- config.scan()
+ config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever() \ No newline at end of file
diff --git a/docs/getting_started/quick_glance/view_classes/delete.jinja2 b/docs/getting_started/quick_glance/view_classes/delete.jinja2
new file mode 100644
index 000000000..ba45b7d16
--- /dev/null
+++ b/docs/getting_started/quick_glance/view_classes/delete.jinja2
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Delete World</title>
+</head>
+<body>
+<h1>Delete {{ view.name }}!</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/docs/getting_started/quick_glance/view_classes/edit.jinja2 b/docs/getting_started/quick_glance/view_classes/edit.jinja2
new file mode 100644
index 000000000..ce0eb5bd1
--- /dev/null
+++ b/docs/getting_started/quick_glance/view_classes/edit.jinja2
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Edit World</title>
+</head>
+<body>
+<h1>Edit {{ view.name }}!</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/docs/getting_started/quick_glance/view_classes/hello.jinja2 b/docs/getting_started/quick_glance/view_classes/hello.jinja2
new file mode 100644
index 000000000..3446b96ce
--- /dev/null
+++ b/docs/getting_started/quick_glance/view_classes/hello.jinja2
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Hello World</title>
+</head>
+<body>
+<h1>Hello {{ view.name }}!</h1>
+<!-- Start Form 1 -->
+<form method="POST"
+ action="{{ request.current_route_url() }}">
+ <input name="new_name"/>
+ <input type="submit" name="form.edit" value="Save"/>
+ <input type="submit" name="form.delete" value="Delete"/>
+</form>
+<!-- End Form 1 -->
+</body>
+</html> \ No newline at end of file
diff --git a/docs/getting_started/quick_glance/view_classes/views.py b/docs/getting_started/quick_glance/view_classes/views.py
new file mode 100644
index 000000000..62556142e
--- /dev/null
+++ b/docs/getting_started/quick_glance/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