summaryrefslogtreecommitdiff
path: root/docs/quick_tour
diff options
context:
space:
mode:
Diffstat (limited to 'docs/quick_tour')
-rw-r--r--docs/quick_tour/hello_world/app.py16
-rw-r--r--docs/quick_tour/jinja2/app.py11
-rw-r--r--docs/quick_tour/jinja2/hello_world.jinja29
-rw-r--r--docs/quick_tour/jinja2/views.py6
-rw-r--r--docs/quick_tour/json/app.py13
-rw-r--r--docs/quick_tour/json/hello_world.jinja210
-rw-r--r--docs/quick_tour/json/views.py11
-rw-r--r--docs/quick_tour/package/CHANGES.txt4
-rw-r--r--docs/quick_tour/package/MANIFEST.in2
-rw-r--r--docs/quick_tour/package/README.txt4
-rw-r--r--docs/quick_tour/package/development.ini61
-rw-r--r--docs/quick_tour/package/hello_world/__init__.py26
-rw-r--r--docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.mobin0 -> 460 bytes
-rw-r--r--docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.po21
-rw-r--r--docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.mobin0 -> 461 bytes
-rw-r--r--docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.po21
-rw-r--r--docs/quick_tour/package/hello_world/locale/hello_world.pot21
-rw-r--r--docs/quick_tour/package/hello_world/resources.py8
-rw-r--r--docs/quick_tour/package/hello_world/static/favicon.icobin0 -> 1406 bytes
-rw-r--r--docs/quick_tour/package/hello_world/static/pyramid-16x16.pngbin0 -> 1319 bytes
-rw-r--r--docs/quick_tour/package/hello_world/static/pyramid.pngbin0 -> 12901 bytes
-rw-r--r--docs/quick_tour/package/hello_world/static/theme.css153
-rw-r--r--docs/quick_tour/package/hello_world/templates/mytemplate.jinja272
-rw-r--r--docs/quick_tour/package/hello_world/tests.py20
-rw-r--r--docs/quick_tour/package/hello_world/views.py16
-rw-r--r--docs/quick_tour/package/message-extraction.ini3
-rw-r--r--docs/quick_tour/package/setup.cfg28
-rw-r--r--docs/quick_tour/package/setup.py44
-rw-r--r--docs/quick_tour/requests/app.py24
-rw-r--r--docs/quick_tour/routing/app.py10
-rw-r--r--docs/quick_tour/routing/views.py8
-rw-r--r--docs/quick_tour/sqla_demo/CHANGES.txt4
-rw-r--r--docs/quick_tour/sqla_demo/MANIFEST.in2
-rw-r--r--docs/quick_tour/sqla_demo/README.txt14
-rw-r--r--docs/quick_tour/sqla_demo/development.ini71
-rw-r--r--docs/quick_tour/sqla_demo/production.ini62
-rw-r--r--docs/quick_tour/sqla_demo/setup.cfg27
-rw-r--r--docs/quick_tour/sqla_demo/setup.py47
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/__init__.py13
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/models/__init__.py7
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/models/meta.py49
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/models/mymodel.py19
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/scripts/__init__.py1
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/scripts/initializedb.py45
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/static/pyramid-16x16.pngbin0 -> 1319 bytes
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/static/pyramid.pngbin0 -> 12901 bytes
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/static/theme.css154
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja266
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja28
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/tests.py65
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/views/__init__.py0
-rw-r--r--docs/quick_tour/sqla_demo/sqla_demo/views/default.py35
-rw-r--r--docs/quick_tour/static_assets/app.py12
-rw-r--r--docs/quick_tour/static_assets/hello_world.jinja210
-rw-r--r--docs/quick_tour/static_assets/hello_world_static.jinja210
-rw-r--r--docs/quick_tour/static_assets/static/app.css4
-rw-r--r--docs/quick_tour/static_assets/views.py6
-rw-r--r--docs/quick_tour/templating/app.py11
-rw-r--r--docs/quick_tour/templating/hello_world.pt9
-rw-r--r--docs/quick_tour/templating/views.py6
-rw-r--r--docs/quick_tour/view_classes/app.py13
-rw-r--r--docs/quick_tour/view_classes/delete.jinja29
-rw-r--r--docs/quick_tour/view_classes/edit.jinja29
-rw-r--r--docs/quick_tour/view_classes/hello.jinja215
-rw-r--r--docs/quick_tour/view_classes/views.py30
-rw-r--r--docs/quick_tour/views/app.py13
-rw-r--r--docs/quick_tour/views/views.py32
67 files changed, 1500 insertions, 0 deletions
diff --git a/docs/quick_tour/hello_world/app.py b/docs/quick_tour/hello_world/app.py
new file mode 100644
index 000000000..75d22ac96
--- /dev/null
+++ b/docs/quick_tour/hello_world/app.py
@@ -0,0 +1,16 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+from pyramid.response import Response
+
+
+def hello_world(request):
+ return Response('<h1>Hello World!</h1>')
+
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('hello', '/')
+ config.add_view(hello_world, route_name='hello')
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 6543, app)
+ server.serve_forever()
diff --git a/docs/quick_tour/jinja2/app.py b/docs/quick_tour/jinja2/app.py
new file mode 100644
index 000000000..b7632807b
--- /dev/null
+++ b/docs/quick_tour/jinja2/app.py
@@ -0,0 +1,11 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('hello', '/howdy/{name}')
+ config.include('pyramid_jinja2')
+ config.scan('views')
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 6543, app)
+ server.serve_forever()
diff --git a/docs/quick_tour/jinja2/hello_world.jinja2 b/docs/quick_tour/jinja2/hello_world.jinja2
new file mode 100644
index 000000000..7a902dd3a
--- /dev/null
+++ b/docs/quick_tour/jinja2/hello_world.jinja2
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Hello World</title>
+</head>
+<body>
+<h1>Hello {{ name }}!</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/docs/quick_tour/jinja2/views.py b/docs/quick_tour/jinja2/views.py
new file mode 100644
index 000000000..7dbb45287
--- /dev/null
+++ b/docs/quick_tour/jinja2/views.py
@@ -0,0 +1,6 @@
+from pyramid.view import view_config
+
+
+@view_config(route_name='hello', renderer='hello_world.jinja2')
+def hello_world(request):
+ return dict(name=request.matchdict['name'])
diff --git a/docs/quick_tour/json/app.py b/docs/quick_tour/json/app.py
new file mode 100644
index 000000000..40faddd00
--- /dev/null
+++ b/docs/quick_tour/json/app.py
@@ -0,0 +1,13 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('hello', '/howdy/{name}')
+ config.add_route('hello_json', 'hello.json')
+ config.add_static_view(name='static', path='static')
+ config.include('pyramid_jinja2')
+ config.scan('views')
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 6543, app)
+ server.serve_forever()
diff --git a/docs/quick_tour/json/hello_world.jinja2 b/docs/quick_tour/json/hello_world.jinja2
new file mode 100644
index 000000000..4fb9be074
--- /dev/null
+++ b/docs/quick_tour/json/hello_world.jinja2
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Hello World</title>
+ <link rel="stylesheet" href="{{ request.static_url('static/app.css') }}"/>
+</head>
+<body>
+<h1>Hello {{ name }}!</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/docs/quick_tour/json/views.py b/docs/quick_tour/json/views.py
new file mode 100644
index 000000000..22aa8aad6
--- /dev/null
+++ b/docs/quick_tour/json/views.py
@@ -0,0 +1,11 @@
+from pyramid.view import view_config
+
+
+@view_config(route_name='hello', renderer='hello_world.jinja2')
+def hello_world(request):
+ return dict(name=request.matchdict['name'])
+
+
+@view_config(route_name='hello_json', renderer='json')
+def hello_json(request):
+ return [1, 2, 3]
diff --git a/docs/quick_tour/package/CHANGES.txt b/docs/quick_tour/package/CHANGES.txt
new file mode 100644
index 000000000..ffa255da8
--- /dev/null
+++ b/docs/quick_tour/package/CHANGES.txt
@@ -0,0 +1,4 @@
+0.0
+---
+
+- Initial version
diff --git a/docs/quick_tour/package/MANIFEST.in b/docs/quick_tour/package/MANIFEST.in
new file mode 100644
index 000000000..1d0352f7d
--- /dev/null
+++ b/docs/quick_tour/package/MANIFEST.in
@@ -0,0 +1,2 @@
+include *.txt *.ini *.cfg *.rst
+recursive-include hello_world *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.jinja2 *.js *.html *.xml
diff --git a/docs/quick_tour/package/README.txt b/docs/quick_tour/package/README.txt
new file mode 100644
index 000000000..63aaf6fbd
--- /dev/null
+++ b/docs/quick_tour/package/README.txt
@@ -0,0 +1,4 @@
+hello_world README
+
+
+
diff --git a/docs/quick_tour/package/development.ini b/docs/quick_tour/package/development.ini
new file mode 100644
index 000000000..20f9817a9
--- /dev/null
+++ b/docs/quick_tour/package/development.ini
@@ -0,0 +1,61 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/narr/environment.html
+###
+
+[app:main]
+use = egg:hello_world
+
+pyramid.reload_templates = true
+pyramid.debug_authorization = false
+pyramid.debug_notfound = false
+pyramid.debug_routematch = false
+pyramid.debug_templates = true
+pyramid.default_locale_name = en
+pyramid.includes =
+ pyramid_debugtoolbar
+
+# By default, the toolbar only appears for clients from IP addresses
+# '127.0.0.1' and '::1'.
+# debugtoolbar.hosts = 127.0.0.1 ::1
+
+###
+# wsgi server configuration
+###
+
+[server:main]
+use = egg:waitress#main
+host = 127.0.0.1
+port = 6543
+
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/narr/logging.html
+###
+
+[loggers]
+keys = root, hello_world
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = INFO
+handlers = console
+
+[logger_hello_world]
+level = DEBUG
+handlers =
+qualname = hello_world
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
diff --git a/docs/quick_tour/package/hello_world/__init__.py b/docs/quick_tour/package/hello_world/__init__.py
new file mode 100644
index 000000000..97f93d5a8
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/__init__.py
@@ -0,0 +1,26 @@
+from pyramid.config import Configurator
+from hello_world.resources import get_root
+from pyramid.session import SignedCookieSessionFactory
+
+
+def main(global_config, **settings):
+ """ This function returns a WSGI application.
+
+ It is usually called by the PasteDeploy framework during
+ ``paster serve``.
+ """
+ settings = dict(settings)
+ settings.setdefault('jinja2.i18n.domain', 'hello_world')
+
+ my_session_factory = SignedCookieSessionFactory('itsaseekreet')
+ config = Configurator(root_factory=get_root, settings=settings,
+ session_factory=my_session_factory)
+ config.add_translation_dirs('locale/')
+ config.include('pyramid_jinja2')
+
+ config.add_static_view('static', 'static')
+ config.add_view('hello_world.views.my_view',
+ context='hello_world.resources.MyResource',
+ renderer="templates/mytemplate.jinja2")
+
+ return config.make_wsgi_app()
diff --git a/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.mo b/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.mo
new file mode 100644
index 000000000..40bf0c271
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.mo
Binary files differ
diff --git a/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.po b/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.po
new file mode 100644
index 000000000..0df243dba
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/locale/de/LC_MESSAGES/hello_world.po
@@ -0,0 +1,21 @@
+# Translations template for PROJECT.
+# Copyright (C) 2011 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2011-05-12 09:14-0330\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.6\n"
+
+msgid "Hello!"
+msgstr "Hallo!"
diff --git a/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.mo b/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.mo
new file mode 100644
index 000000000..4fc438bfe
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.mo
Binary files differ
diff --git a/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.po b/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.po
new file mode 100644
index 000000000..dc0aae5d7
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/locale/fr/LC_MESSAGES/hello_world.po
@@ -0,0 +1,21 @@
+# Translations template for PROJECT.
+# Copyright (C) 2011 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2011-05-12 09:14-0330\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.6\n"
+
+msgid "Hello!"
+msgstr "Bonjour!"
diff --git a/docs/quick_tour/package/hello_world/locale/hello_world.pot b/docs/quick_tour/package/hello_world/locale/hello_world.pot
new file mode 100644
index 000000000..9c9460cb2
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/locale/hello_world.pot
@@ -0,0 +1,21 @@
+# Translations template for PROJECT.
+# Copyright (C) 2011 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2011-05-12 09:14-0330\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.6\n"
+
+msgid "Hello!"
+msgstr ""
diff --git a/docs/quick_tour/package/hello_world/resources.py b/docs/quick_tour/package/hello_world/resources.py
new file mode 100644
index 000000000..e89c2f363
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/resources.py
@@ -0,0 +1,8 @@
+class MyResource(object):
+ pass
+
+root = MyResource()
+
+
+def get_root(request):
+ return root
diff --git a/docs/quick_tour/package/hello_world/static/favicon.ico b/docs/quick_tour/package/hello_world/static/favicon.ico
new file mode 100644
index 000000000..71f837c9e
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/static/favicon.ico
Binary files differ
diff --git a/docs/quick_tour/package/hello_world/static/pyramid-16x16.png b/docs/quick_tour/package/hello_world/static/pyramid-16x16.png
new file mode 100644
index 000000000..979203112
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/static/pyramid-16x16.png
Binary files differ
diff --git a/docs/quick_tour/package/hello_world/static/pyramid.png b/docs/quick_tour/package/hello_world/static/pyramid.png
new file mode 100644
index 000000000..4ab837be9
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/static/pyramid.png
Binary files differ
diff --git a/docs/quick_tour/package/hello_world/static/theme.css b/docs/quick_tour/package/hello_world/static/theme.css
new file mode 100644
index 000000000..e3cf3f290
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/static/theme.css
@@ -0,0 +1,153 @@
+@import url(//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700);
+body {
+ font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-weight: 300;
+ color: #ffffff;
+ background: #bc2131;
+}
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-weight: 300;
+}
+p {
+ font-weight: 300;
+}
+.font-normal {
+ font-weight: 400;
+}
+.font-semi-bold {
+ font-weight: 600;
+}
+.font-bold {
+ font-weight: 700;
+}
+.starter-template {
+ margin-top: 250px;
+}
+.starter-template .content {
+ margin-left: 10px;
+}
+.starter-template .content h1 {
+ margin-top: 10px;
+ font-size: 60px;
+}
+.starter-template .content h1 .smaller {
+ font-size: 40px;
+ color: #f2b7bd;
+}
+.starter-template .content .lead {
+ font-size: 25px;
+ color: #f2b7bd;
+}
+.starter-template .content .lead .font-normal {
+ color: #ffffff;
+}
+.starter-template .links {
+ float: right;
+ right: 0;
+ margin-top: 125px;
+}
+.starter-template .links ul {
+ display: block;
+ padding: 0;
+ margin: 0;
+}
+.starter-template .links ul li {
+ list-style: none;
+ display: inline;
+ margin: 0 10px;
+}
+.starter-template .links ul li:first-child {
+ margin-left: 0;
+}
+.starter-template .links ul li:last-child {
+ margin-right: 0;
+}
+.starter-template .links ul li.current-version {
+ color: #f2b7bd;
+ font-weight: 400;
+}
+.starter-template .links ul li a {
+ color: #ffffff;
+}
+.starter-template .links ul li a:hover {
+ text-decoration: underline;
+}
+.starter-template .links ul li .icon-muted {
+ color: #eb8b95;
+ margin-right: 5px;
+}
+.starter-template .links ul li:hover .icon-muted {
+ color: #ffffff;
+}
+.starter-template .copyright {
+ margin-top: 10px;
+ font-size: 0.9em;
+ color: #f2b7bd;
+ text-transform: lowercase;
+ float: right;
+ right: 0;
+}
+@media (max-width: 1199px) {
+ .starter-template .content h1 {
+ font-size: 45px;
+ }
+ .starter-template .content h1 .smaller {
+ font-size: 30px;
+ }
+ .starter-template .content .lead {
+ font-size: 20px;
+ }
+}
+@media (max-width: 991px) {
+ .starter-template {
+ margin-top: 0;
+ }
+ .starter-template .logo {
+ margin: 40px auto;
+ }
+ .starter-template .content {
+ margin-left: 0;
+ text-align: center;
+ }
+ .starter-template .content h1 {
+ margin-bottom: 20px;
+ }
+ .starter-template .links {
+ float: none;
+ text-align: center;
+ margin-top: 60px;
+ }
+ .starter-template .copyright {
+ float: none;
+ text-align: center;
+ }
+}
+@media (max-width: 767px) {
+ .starter-template .content h1 .smaller {
+ font-size: 25px;
+ display: block;
+ }
+ .starter-template .content .lead {
+ font-size: 16px;
+ }
+ .starter-template .links {
+ margin-top: 40px;
+ }
+ .starter-template .links ul li {
+ display: block;
+ margin: 0;
+ }
+ .starter-template .links ul li .icon-muted {
+ display: none;
+ }
+ .starter-template .copyright {
+ margin-top: 20px;
+ }
+}
+
diff --git a/docs/quick_tour/package/hello_world/templates/mytemplate.jinja2 b/docs/quick_tour/package/hello_world/templates/mytemplate.jinja2
new file mode 100644
index 000000000..a6089aebc
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/templates/mytemplate.jinja2
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html lang="{{request.locale_name}}">
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="pyramid web application">
+ <meta name="author" content="Pylons Project">
+ <link rel="shortcut icon" href="{{request.static_url('hello_world:static/pyramid-16x16.png')}}">
+
+ <title>Starter Scaffold for Pyramid Jinja2</title>
+
+ <!-- Bootstrap core CSS -->
+ <link href="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
+
+ <!-- Custom styles for this scaffold -->
+ <link href="{{request.static_url('hello_world:static/theme.css')}}" rel="stylesheet">
+
+ <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
+ <!--[if lt IE 9]>
+ <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
+ <script src="//oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
+ <![endif]-->
+ </head>
+
+ <body>
+
+ <div class="starter-template">
+ <div class="container">
+ <div class="row">
+ <div class="col-md-2">
+ <img class="logo img-responsive" src="{{request.static_url('hello_world:static/pyramid.png')}}" alt="pyramid web framework">
+ </div>
+ <div class="col-md-10">
+ <div class="content">
+ <h1>
+ <span class="font-semi-bold">Pyramid</span>
+ <span class="smaller">Jinja2 scaffold</span>
+ </h1>
+ <p class="lead">
+ {% trans %}Hello{% endtrans %} to <span class="font-normal">{{project}}</span>, an&nbsp;application generated&nbsp;by<br>the <span class="font-normal">Pyramid Web Framework 1.6</span>.</p>
+ <p>Counter: {{ request.session.counter }}</p>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="links">
+ <ul>
+ <li class="current-version">Generated by v1.6</li>
+ <li><i class="glyphicon glyphicon-bookmark icon-muted"></i><a href="http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/">Docs</a></li>
+ <li><i class="glyphicon glyphicon-cog icon-muted"></i><a href="https://github.com/Pylons/pyramid">Github Project</a></li>
+ <li><i class="glyphicon glyphicon-globe icon-muted"></i><a href="irc://irc.freenode.net#pyramid">IRC Channel</a></li>
+ <li><i class="glyphicon glyphicon-home icon-muted"></i><a href="http://pylonsproject.org">Pylons Project</a></li>
+ </ul>
+ </div>
+ </div>
+ <div class="row">
+ <div class="copyright">
+ Copyright &copy; Pylons Project
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+ <!-- Bootstrap core JavaScript
+ ================================================== -->
+ <!-- Placed at the end of the document so the pages load faster -->
+ <script src="//oss.maxcdn.com/libs/jquery/1.10.2/jquery.min.js"></script>
+ <script src="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
+ </body>
+</html>
diff --git a/docs/quick_tour/package/hello_world/tests.py b/docs/quick_tour/package/hello_world/tests.py
new file mode 100644
index 000000000..ccec14f70
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/tests.py
@@ -0,0 +1,20 @@
+import unittest
+from pyramid import testing
+from pyramid.i18n import TranslationStringFactory
+
+_ = TranslationStringFactory('hello_world')
+
+
+class ViewTests(unittest.TestCase):
+
+ def setUp(self):
+ testing.setUp()
+
+ def tearDown(self):
+ testing.tearDown()
+
+ def test_my_view(self):
+ from hello_world.views import my_view
+ request = testing.DummyRequest()
+ response = my_view(request)
+ self.assertEqual(response['project'], 'hello_world')
diff --git a/docs/quick_tour/package/hello_world/views.py b/docs/quick_tour/package/hello_world/views.py
new file mode 100644
index 000000000..9f7953c8e
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/views.py
@@ -0,0 +1,16 @@
+from pyramid.i18n import TranslationStringFactory
+
+import logging
+log = logging.getLogger(__name__)
+
+_ = TranslationStringFactory('hello_world')
+
+
+def my_view(request):
+ log.debug('Some Message')
+ session = request.session
+ if 'counter' in session:
+ session['counter'] += 1
+ else:
+ session['counter'] = 0
+ return {'project': 'hello_world'}
diff --git a/docs/quick_tour/package/message-extraction.ini b/docs/quick_tour/package/message-extraction.ini
new file mode 100644
index 000000000..0c3d54bc1
--- /dev/null
+++ b/docs/quick_tour/package/message-extraction.ini
@@ -0,0 +1,3 @@
+[python: **.py]
+[jinja2: **.jinja2]
+encoding = utf-8
diff --git a/docs/quick_tour/package/setup.cfg b/docs/quick_tour/package/setup.cfg
new file mode 100644
index 000000000..186e796fc
--- /dev/null
+++ b/docs/quick_tour/package/setup.cfg
@@ -0,0 +1,28 @@
+[nosetests]
+match = ^test
+nocapture = 1
+cover-package = hello_world
+with-coverage = 1
+cover-erase = 1
+
+[compile_catalog]
+directory = hello_world/locale
+domain = hello_world
+statistics = true
+
+[extract_messages]
+add_comments = TRANSLATORS:
+output_file = hello_world/locale/hello_world.pot
+width = 80
+mapping_file = message-extraction.ini
+
+[init_catalog]
+domain = hello_world
+input_file = hello_world/locale/hello_world.pot
+output_dir = hello_world/locale
+
+[update_catalog]
+domain = hello_world
+input_file = hello_world/locale/hello_world.pot
+output_dir = hello_world/locale
+previous = true
diff --git a/docs/quick_tour/package/setup.py b/docs/quick_tour/package/setup.py
new file mode 100644
index 000000000..61ed3c406
--- /dev/null
+++ b/docs/quick_tour/package/setup.py
@@ -0,0 +1,44 @@
+import os
+
+from setuptools import setup, find_packages
+
+here = os.path.abspath(os.path.dirname(__file__))
+with open(os.path.join(here, 'README.txt')) as f:
+ README = f.read()
+with open(os.path.join(here, 'CHANGES.txt')) as f:
+ CHANGES = f.read()
+
+requires = [
+ 'pyramid',
+ 'pyramid_jinja2',
+ 'pyramid_debugtoolbar',
+ 'waitress',
+]
+
+setup(name='hello_world',
+ version='0.0',
+ description='hello_world',
+ long_description=README + '\n\n' + CHANGES,
+ classifiers=[
+ "Programming Language :: Python",
+ "Framework :: Pyramid",
+ "Topic :: Internet :: WWW/HTTP",
+ "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
+ ],
+ author='',
+ author_email='',
+ url='',
+ keywords='web pyramid pylons',
+ packages=find_packages(),
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=requires,
+ tests_require={
+ 'testing': ['nose', 'coverage'],
+ },
+ test_suite="hello_world",
+ entry_points="""\
+ [paste.app_factory]
+ main = hello_world:main
+ """,
+ )
diff --git a/docs/quick_tour/requests/app.py b/docs/quick_tour/requests/app.py
new file mode 100644
index 000000000..f55264cff
--- /dev/null
+++ b/docs/quick_tour/requests/app.py
@@ -0,0 +1,24 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+from pyramid.response import Response
+
+
+def hello_world(request):
+ # Some parameters from a request such as /?name=lisa
+ url = request.url
+ name = request.params.get('name', 'No Name Provided')
+
+ body = 'URL %s with name: %s' % (url, name)
+ return Response(
+ content_type="text/plain",
+ body=body
+ )
+
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('hello', '/')
+ config.add_view(hello_world, route_name='hello')
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 6543, app)
+ server.serve_forever()
diff --git a/docs/quick_tour/routing/app.py b/docs/quick_tour/routing/app.py
new file mode 100644
index 000000000..12b547bfe
--- /dev/null
+++ b/docs/quick_tour/routing/app.py
@@ -0,0 +1,10 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('hello', '/howdy/{first}/{last}')
+ 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/quick_tour/routing/views.py b/docs/quick_tour/routing/views.py
new file mode 100644
index 000000000..8a3bd230e
--- /dev/null
+++ b/docs/quick_tour/routing/views.py
@@ -0,0 +1,8 @@
+from pyramid.response import Response
+from pyramid.view import view_config
+
+
+@view_config(route_name='hello')
+def hello_world(request):
+ body = '<h1>Hi %(first)s %(last)s!</h1>' % request.matchdict
+ return Response(body)
diff --git a/docs/quick_tour/sqla_demo/CHANGES.txt b/docs/quick_tour/sqla_demo/CHANGES.txt
new file mode 100644
index 000000000..35a34f332
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/CHANGES.txt
@@ -0,0 +1,4 @@
+0.0
+---
+
+- Initial version
diff --git a/docs/quick_tour/sqla_demo/MANIFEST.in b/docs/quick_tour/sqla_demo/MANIFEST.in
new file mode 100644
index 000000000..a432577e9
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/MANIFEST.in
@@ -0,0 +1,2 @@
+include *.txt *.ini *.cfg *.rst
+recursive-include sqla_demo *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml
diff --git a/docs/quick_tour/sqla_demo/README.txt b/docs/quick_tour/sqla_demo/README.txt
new file mode 100644
index 000000000..b6d4c7798
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/README.txt
@@ -0,0 +1,14 @@
+sqla_demo README
+==================
+
+Getting Started
+---------------
+
+- cd <directory containing this file>
+
+- $VENV/bin/pip install -e .
+
+- $VENV/bin/initialize_sqla_demo_db development.ini
+
+- $VENV/bin/pserve development.ini
+
diff --git a/docs/quick_tour/sqla_demo/development.ini b/docs/quick_tour/sqla_demo/development.ini
new file mode 100644
index 000000000..0db0950a0
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/development.ini
@@ -0,0 +1,71 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
+[app:main]
+use = egg:sqla_demo
+
+pyramid.reload_templates = true
+pyramid.debug_authorization = false
+pyramid.debug_notfound = false
+pyramid.debug_routematch = false
+pyramid.default_locale_name = en
+pyramid.includes =
+ pyramid_debugtoolbar
+ pyramid_tm
+
+sqlalchemy.url = sqlite:///%(here)s/sqla_demo.sqlite
+
+# By default, the toolbar only appears for clients from IP addresses
+# '127.0.0.1' and '::1'.
+# debugtoolbar.hosts = 127.0.0.1 ::1
+
+###
+# wsgi server configuration
+###
+
+[server:main]
+use = egg:waitress#main
+host = 127.0.0.1
+port = 6543
+
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
+
+[loggers]
+keys = root, sqla_demo, sqlalchemy
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = INFO
+handlers = console
+
+[logger_sqla_demo]
+level = DEBUG
+handlers =
+qualname = sqla_demo
+
+[logger_sqlalchemy]
+level = INFO
+handlers =
+qualname = sqlalchemy.engine
+# "level = INFO" logs SQL queries.
+# "level = DEBUG" logs SQL queries and results.
+# "level = WARN" logs neither. (Recommended for production systems.)
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
diff --git a/docs/quick_tour/sqla_demo/production.ini b/docs/quick_tour/sqla_demo/production.ini
new file mode 100644
index 000000000..38f3b6318
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/production.ini
@@ -0,0 +1,62 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
+[app:main]
+use = egg:sqla_demo
+
+pyramid.reload_templates = false
+pyramid.debug_authorization = false
+pyramid.debug_notfound = false
+pyramid.debug_routematch = false
+pyramid.default_locale_name = en
+pyramid.includes =
+ pyramid_tm
+
+sqlalchemy.url = sqlite:///%(here)s/sqla_demo.sqlite
+
+[server:main]
+use = egg:waitress#main
+host = 0.0.0.0
+port = 6543
+
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
+
+[loggers]
+keys = root, sqla_demo, sqlalchemy
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = WARN
+handlers = console
+
+[logger_sqla_demo]
+level = WARN
+handlers =
+qualname = sqla_demo
+
+[logger_sqlalchemy]
+level = WARN
+handlers =
+qualname = sqlalchemy.engine
+# "level = INFO" logs SQL queries.
+# "level = DEBUG" logs SQL queries and results.
+# "level = WARN" logs neither. (Recommended for production systems.)
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
diff --git a/docs/quick_tour/sqla_demo/setup.cfg b/docs/quick_tour/sqla_demo/setup.cfg
new file mode 100644
index 000000000..9f91cd122
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/setup.cfg
@@ -0,0 +1,27 @@
+[nosetests]
+match=^test
+nocapture=1
+cover-package=sqla_demo
+with-coverage=1
+cover-erase=1
+
+[compile_catalog]
+directory = sqla_demo/locale
+domain = sqla_demo
+statistics = true
+
+[extract_messages]
+add_comments = TRANSLATORS:
+output_file = sqla_demo/locale/sqla_demo.pot
+width = 80
+
+[init_catalog]
+domain = sqla_demo
+input_file = sqla_demo/locale/sqla_demo.pot
+output_dir = sqla_demo/locale
+
+[update_catalog]
+domain = sqla_demo
+input_file = sqla_demo/locale/sqla_demo.pot
+output_dir = sqla_demo/locale
+previous = true
diff --git a/docs/quick_tour/sqla_demo/setup.py b/docs/quick_tour/sqla_demo/setup.py
new file mode 100644
index 000000000..312a97c06
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/setup.py
@@ -0,0 +1,47 @@
+import os
+
+from setuptools import setup, find_packages
+
+here = os.path.abspath(os.path.dirname(__file__))
+with open(os.path.join(here, 'README.txt')) as f:
+ README = f.read()
+with open(os.path.join(here, 'CHANGES.txt')) as f:
+ CHANGES = f.read()
+
+requires = [
+ 'pyramid',
+ 'pyramid_jinja2',
+ 'pyramid_debugtoolbar',
+ 'pyramid_tm',
+ 'SQLAlchemy',
+ 'transaction',
+ 'zope.sqlalchemy',
+ 'waitress',
+ ]
+
+setup(name='sqla_demo',
+ version='0.0',
+ description='sqla_demo',
+ long_description=README + '\n\n' + CHANGES,
+ classifiers=[
+ "Programming Language :: Python",
+ "Framework :: Pyramid",
+ "Topic :: Internet :: WWW/HTTP",
+ "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
+ ],
+ author='',
+ author_email='',
+ url='',
+ keywords='web wsgi bfg pylons pyramid',
+ packages=find_packages(),
+ include_package_data=True,
+ zip_safe=False,
+ test_suite='sqla_demo',
+ install_requires=requires,
+ entry_points="""\
+ [paste.app_factory]
+ main = sqla_demo:main
+ [console_scripts]
+ initialize_sqla_demo_db = sqla_demo.scripts.initializedb:main
+ """,
+ )
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/__init__.py b/docs/quick_tour/sqla_demo/sqla_demo/__init__.py
new file mode 100644
index 000000000..7994bbfa8
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/__init__.py
@@ -0,0 +1,13 @@
+from pyramid.config import Configurator
+
+
+def main(global_config, **settings):
+ """ This function returns a Pyramid WSGI application.
+ """
+ config = Configurator(settings=settings)
+ config.include('pyramid_jinja2')
+ config.include('.models.meta')
+ config.add_static_view('static', 'static', cache_max_age=3600)
+ config.add_route('home', '/')
+ config.scan()
+ return config.make_wsgi_app()
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/models/__init__.py b/docs/quick_tour/sqla_demo/sqla_demo/models/__init__.py
new file mode 100644
index 000000000..6ffc10a78
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/models/__init__.py
@@ -0,0 +1,7 @@
+from sqlalchemy.orm import configure_mappers
+# import all models classes here for sqlalchemy mappers
+# to pick up
+from .mymodel import MyModel # flake8: noqa
+
+# run configure mappers to ensure we avoid any race conditions
+configure_mappers()
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/models/meta.py b/docs/quick_tour/sqla_demo/sqla_demo/models/meta.py
new file mode 100644
index 000000000..80ececd8c
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/models/meta.py
@@ -0,0 +1,49 @@
+from sqlalchemy import engine_from_config
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import sessionmaker
+from sqlalchemy.schema import MetaData
+import zope.sqlalchemy
+
+# Recommended naming convention used by Alembic, as various different database
+# providers will autogenerate vastly different names making migrations more
+# difficult. See: http://alembic.readthedocs.org/en/latest/naming.html
+NAMING_CONVENTION = {
+ "ix": 'ix_%(column_0_label)s',
+ "uq": "uq_%(table_name)s_%(column_0_name)s",
+ "ck": "ck_%(table_name)s_%(constraint_name)s",
+ "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
+ "pk": "pk_%(table_name)s"
+}
+
+metadata = MetaData(naming_convention=NAMING_CONVENTION)
+Base = declarative_base(metadata=metadata)
+
+
+def includeme(config):
+ settings = config.get_settings()
+ dbmaker = get_dbmaker(get_engine(settings))
+
+ config.add_request_method(
+ lambda r: get_session(r.tm, dbmaker),
+ 'dbsession',
+ reify=True
+ )
+
+ config.include('pyramid_tm')
+
+
+def get_session(transaction_manager, dbmaker):
+ dbsession = dbmaker()
+ zope.sqlalchemy.register(dbsession,
+ transaction_manager=transaction_manager)
+ return dbsession
+
+
+def get_engine(settings, prefix='sqlalchemy.'):
+ return engine_from_config(settings, prefix)
+
+
+def get_dbmaker(engine):
+ dbmaker = sessionmaker()
+ dbmaker.configure(bind=engine)
+ return dbmaker
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/models/mymodel.py b/docs/quick_tour/sqla_demo/sqla_demo/models/mymodel.py
new file mode 100644
index 000000000..eb645bfe6
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/models/mymodel.py
@@ -0,0 +1,19 @@
+from .meta import Base
+from sqlalchemy import (
+ Column,
+ Index,
+ Integer,
+ Text,
+)
+
+
+# Start Sphinx Include
+class MyModel(Base):
+ __tablename__ = 'models'
+ id = Column(Integer, primary_key=True)
+ name = Column(Text)
+ value = Column(Integer)
+ # End Sphinx Include
+
+
+Index('my_index', MyModel.name, unique=True, mysql_length=255)
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/scripts/__init__.py b/docs/quick_tour/sqla_demo/sqla_demo/scripts/__init__.py
new file mode 100644
index 000000000..5bb534f79
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/scripts/__init__.py
@@ -0,0 +1 @@
+# package
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/scripts/initializedb.py b/docs/quick_tour/sqla_demo/sqla_demo/scripts/initializedb.py
new file mode 100644
index 000000000..f0d09729e
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/scripts/initializedb.py
@@ -0,0 +1,45 @@
+import os
+import sys
+import transaction
+
+from pyramid.paster import (
+ get_appsettings,
+ setup_logging,
+ )
+
+from pyramid.scripts.common import parse_vars
+
+from ..models.meta import (
+ Base,
+ get_session,
+ get_engine,
+ get_dbmaker,
+ )
+from ..models.mymodel import MyModel
+
+
+def usage(argv):
+ cmd = os.path.basename(argv[0])
+ print('usage: %s <config_uri> [var=value]\n'
+ '(example: "%s development.ini")' % (cmd, cmd))
+ sys.exit(1)
+
+
+def main(argv=sys.argv):
+ if len(argv) < 2:
+ usage(argv)
+ config_uri = argv[1]
+ options = parse_vars(argv[2:])
+ setup_logging(config_uri)
+ settings = get_appsettings(config_uri, options=options)
+
+ engine = get_engine(settings)
+ dbmaker = get_dbmaker(engine)
+
+ dbsession = get_session(transaction.manager, dbmaker)
+
+ Base.metadata.create_all(engine)
+
+ with transaction.manager:
+ model = MyModel(name='one', value=1)
+ dbsession.add(model)
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/static/pyramid-16x16.png b/docs/quick_tour/sqla_demo/sqla_demo/static/pyramid-16x16.png
new file mode 100644
index 000000000..979203112
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/static/pyramid-16x16.png
Binary files differ
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/static/pyramid.png b/docs/quick_tour/sqla_demo/sqla_demo/static/pyramid.png
new file mode 100644
index 000000000..4ab837be9
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/static/pyramid.png
Binary files differ
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/static/theme.css b/docs/quick_tour/sqla_demo/sqla_demo/static/theme.css
new file mode 100644
index 000000000..0f4b1a4d4
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/static/theme.css
@@ -0,0 +1,154 @@
+@import url(//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700);
+body {
+ font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-weight: 300;
+ color: #ffffff;
+ background: #bc2131;
+}
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-weight: 300;
+}
+p {
+ font-weight: 300;
+}
+.font-normal {
+ font-weight: 400;
+}
+.font-semi-bold {
+ font-weight: 600;
+}
+.font-bold {
+ font-weight: 700;
+}
+.starter-template {
+ margin-top: 250px;
+}
+.starter-template .content {
+ margin-left: 10px;
+}
+.starter-template .content h1 {
+ margin-top: 10px;
+ font-size: 60px;
+}
+.starter-template .content h1 .smaller {
+ font-size: 40px;
+ color: #f2b7bd;
+}
+.starter-template .content .lead {
+ font-size: 25px;
+ color: #f2b7bd;
+}
+.starter-template .content .lead .font-normal {
+ color: #ffffff;
+}
+.starter-template .links {
+ float: right;
+ right: 0;
+ margin-top: 125px;
+}
+.starter-template .links ul {
+ display: block;
+ padding: 0;
+ margin: 0;
+}
+.starter-template .links ul li {
+ list-style: none;
+ display: inline;
+ margin: 0 10px;
+}
+.starter-template .links ul li:first-child {
+ margin-left: 0;
+}
+.starter-template .links ul li:last-child {
+ margin-right: 0;
+}
+.starter-template .links ul li.current-version {
+ color: #f2b7bd;
+ font-weight: 400;
+}
+.starter-template .links ul li a, a {
+ color: #f2b7bd;
+ text-decoration: underline;
+}
+.starter-template .links ul li a:hover, a:hover {
+ color: #ffffff;
+ text-decoration: underline;
+}
+.starter-template .links ul li .icon-muted {
+ color: #eb8b95;
+ margin-right: 5px;
+}
+.starter-template .links ul li:hover .icon-muted {
+ color: #ffffff;
+}
+.starter-template .copyright {
+ margin-top: 10px;
+ font-size: 0.9em;
+ color: #f2b7bd;
+ text-transform: lowercase;
+ float: right;
+ right: 0;
+}
+@media (max-width: 1199px) {
+ .starter-template .content h1 {
+ font-size: 45px;
+ }
+ .starter-template .content h1 .smaller {
+ font-size: 30px;
+ }
+ .starter-template .content .lead {
+ font-size: 20px;
+ }
+}
+@media (max-width: 991px) {
+ .starter-template {
+ margin-top: 0;
+ }
+ .starter-template .logo {
+ margin: 40px auto;
+ }
+ .starter-template .content {
+ margin-left: 0;
+ text-align: center;
+ }
+ .starter-template .content h1 {
+ margin-bottom: 20px;
+ }
+ .starter-template .links {
+ float: none;
+ text-align: center;
+ margin-top: 60px;
+ }
+ .starter-template .copyright {
+ float: none;
+ text-align: center;
+ }
+}
+@media (max-width: 767px) {
+ .starter-template .content h1 .smaller {
+ font-size: 25px;
+ display: block;
+ }
+ .starter-template .content .lead {
+ font-size: 16px;
+ }
+ .starter-template .links {
+ margin-top: 40px;
+ }
+ .starter-template .links ul li {
+ display: block;
+ margin: 0;
+ }
+ .starter-template .links ul li .icon-muted {
+ display: none;
+ }
+ .starter-template .copyright {
+ margin-top: 20px;
+ }
+}
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 b/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2
new file mode 100644
index 000000000..76a098122
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html lang="{{request.locale_name}}">
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="pyramid web application">
+ <meta name="author" content="Pylons Project">
+ <link rel="shortcut icon" href="{{request.static_url('sqla_demo:static/pyramid-16x16.png')}}">
+
+ <title>Alchemy Scaffold for The Pyramid Web Framework</title>
+
+ <!-- Bootstrap core CSS -->
+ <link href="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
+
+ <!-- Custom styles for this scaffold -->
+ <link href="{{request.static_url('sqla_demo:static/theme.css')}}" rel="stylesheet">
+
+ <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
+ <!--[if lt IE 9]>
+ <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
+ <script src="//oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
+ <![endif]-->
+ </head>
+
+ <body>
+
+ <div class="starter-template">
+ <div class="container">
+ <div class="row">
+ <div class="col-md-2">
+ <img class="logo img-responsive" src="{{request.static_url('sqla_demo:static/pyramid.png')}}" alt="pyramid web framework">
+ </div>
+ <div class="col-md-10">
+ {% block content %}
+ <p>No content</p>
+ {% endblock content %}
+ </div>
+ </div>
+ <div class="row">
+ <div class="links">
+ <ul>
+ <li class="current-version">Generated by v1.7.dev0</li>
+ <li><i class="glyphicon glyphicon-bookmark icon-muted"></i><a href="http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/">Docs</a></li>
+ <li><i class="glyphicon glyphicon-cog icon-muted"></i><a href="https://github.com/Pylons/pyramid">Github Project</a></li>
+ <li><i class="glyphicon glyphicon-globe icon-muted"></i><a href="irc://irc.freenode.net#pyramid">IRC Channel</a></li>
+ <li><i class="glyphicon glyphicon-home icon-muted"></i><a href="http://pylonsproject.org">Pylons Project</a></li>
+ </ul>
+ </div>
+ </div>
+ <div class="row">
+ <div class="copyright">
+ Copyright &copy; Pylons Project
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+ <!-- Bootstrap core JavaScript
+ ================================================== -->
+ <!-- Placed at the end of the document so the pages load faster -->
+ <script src="//oss.maxcdn.com/libs/jquery/1.10.2/jquery.min.js"></script>
+ <script src="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
+ </body>
+</html>
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 b/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2
new file mode 100644
index 000000000..bb622bf5a
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2
@@ -0,0 +1,8 @@
+{% extends "layout.jinja2" %}
+
+{% block content %}
+<div class="content">
+ <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy scaffold</span></h1>
+ <p class="lead">Welcome to <span class="font-normal">{{project}}</span>, an&nbsp;application generated&nbsp;by<br>the <span class="font-normal">Pyramid Web Framework 1.7.dev0</span>.</p>
+</div>
+{% endblock content %}
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/tests.py b/docs/quick_tour/sqla_demo/sqla_demo/tests.py
new file mode 100644
index 000000000..b6b6fdf4d
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/tests.py
@@ -0,0 +1,65 @@
+import unittest
+import transaction
+
+from pyramid import testing
+
+
+def dummy_request(dbsession):
+ return testing.DummyRequest(dbsession=dbsession)
+
+
+class BaseTest(unittest.TestCase):
+ def setUp(self):
+ self.config = testing.setUp(settings={
+ 'sqlalchemy.url': 'sqlite:///:memory:'
+ })
+ self.config.include('.models.meta')
+ settings = self.config.get_settings()
+
+ from .models.meta import (
+ get_session,
+ get_engine,
+ get_dbmaker,
+ )
+
+ self.engine = get_engine(settings)
+ dbmaker = get_dbmaker(self.engine)
+
+ self.session = get_session(transaction.manager, dbmaker)
+
+ def init_database(self):
+ from .models.meta import Base
+ Base.metadata.create_all(self.engine)
+
+ def tearDown(self):
+ from .models.meta import Base
+
+ testing.tearDown()
+ transaction.abort()
+ Base.metadata.create_all(self.engine)
+
+
+class TestMyViewSuccessCondition(BaseTest):
+
+ def setUp(self):
+ super(TestMyViewSuccessCondition, self).setUp()
+ self.init_database()
+
+ from .models.mymodel import MyModel
+
+ model = MyModel(name='one', value=55)
+ self.session.add(model)
+
+ def test_passing_view(self):
+ from .views.default import my_view
+ info = my_view(dummy_request(self.session))
+ self.assertEqual(info['one'].name, 'one')
+ self.assertEqual(info['project'], 'sqla_demo')
+
+
+class TestMyViewFailureCondition(BaseTest):
+
+ def test_failing_view(self):
+ from .views.default import my_view
+ info = my_view(dummy_request(self.session))
+ self.assertEqual(info.status_int, 500)
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/views/__init__.py b/docs/quick_tour/sqla_demo/sqla_demo/views/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/views/__init__.py
diff --git a/docs/quick_tour/sqla_demo/sqla_demo/views/default.py b/docs/quick_tour/sqla_demo/sqla_demo/views/default.py
new file mode 100644
index 000000000..e5e70cf9d
--- /dev/null
+++ b/docs/quick_tour/sqla_demo/sqla_demo/views/default.py
@@ -0,0 +1,35 @@
+from pyramid.response import Response
+from pyramid.view import view_config
+
+from sqlalchemy.exc import DBAPIError
+
+from ..models.mymodel import MyModel
+
+
+@view_config(route_name='home', renderer='../templates/mytemplate.jinja2')
+def my_view(request):
+ try:
+ query = request.dbsession.query(MyModel)
+ # Start Sphinx Include
+ one = query.filter(MyModel.name == 'one').first()
+ # End Sphinx Include
+ except DBAPIError:
+ return Response(db_err_msg, content_type='text/plain', status_int=500)
+ return {'one': one, 'project': 'sqla_demo'}
+
+
+db_err_msg = """\
+Pyramid is having a problem using your SQL database. The problem
+might be caused by one of the following things:
+
+1. You may need to run the "initialize_sqla_demo_db" script
+ to initialize your database tables. Check your virtual
+ environment's "bin" directory for this script and try to run it.
+
+2. Your database server may not be running. Check that the
+ database server referred to by the "sqlalchemy.url" setting in
+ your "development.ini" file is running.
+
+After you fix the problem, please restart the Pyramid application to
+try it again.
+"""
diff --git a/docs/quick_tour/static_assets/app.py b/docs/quick_tour/static_assets/app.py
new file mode 100644
index 000000000..1849c0a5a
--- /dev/null
+++ b/docs/quick_tour/static_assets/app.py
@@ -0,0 +1,12 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('hello', '/howdy/{name}')
+ config.add_static_view(name='static', path='static')
+ config.include('pyramid_jinja2')
+ config.scan('views')
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 6543, app)
+ server.serve_forever()
diff --git a/docs/quick_tour/static_assets/hello_world.jinja2 b/docs/quick_tour/static_assets/hello_world.jinja2
new file mode 100644
index 000000000..0fb2ce296
--- /dev/null
+++ b/docs/quick_tour/static_assets/hello_world.jinja2
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Hello World</title>
+ <link rel="stylesheet" href="/static/app.css"/>
+</head>
+<body>
+<h1>Hello {{ name }}!</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/docs/quick_tour/static_assets/hello_world_static.jinja2 b/docs/quick_tour/static_assets/hello_world_static.jinja2
new file mode 100644
index 000000000..4fb9be074
--- /dev/null
+++ b/docs/quick_tour/static_assets/hello_world_static.jinja2
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Hello World</title>
+ <link rel="stylesheet" href="{{ request.static_url('static/app.css') }}"/>
+</head>
+<body>
+<h1>Hello {{ name }}!</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/docs/quick_tour/static_assets/static/app.css b/docs/quick_tour/static_assets/static/app.css
new file mode 100644
index 000000000..f8acf3164
--- /dev/null
+++ b/docs/quick_tour/static_assets/static/app.css
@@ -0,0 +1,4 @@
+body {
+ margin: 2em;
+ font-family: sans-serif;
+} \ No newline at end of file
diff --git a/docs/quick_tour/static_assets/views.py b/docs/quick_tour/static_assets/views.py
new file mode 100644
index 000000000..7dbb45287
--- /dev/null
+++ b/docs/quick_tour/static_assets/views.py
@@ -0,0 +1,6 @@
+from pyramid.view import view_config
+
+
+@view_config(route_name='hello', renderer='hello_world.jinja2')
+def hello_world(request):
+ return dict(name=request.matchdict['name'])
diff --git a/docs/quick_tour/templating/app.py b/docs/quick_tour/templating/app.py
new file mode 100644
index 000000000..52b7faf55
--- /dev/null
+++ b/docs/quick_tour/templating/app.py
@@ -0,0 +1,11 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('hello', '/howdy/{name}')
+ config.include('pyramid_chameleon')
+ config.scan('views')
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 6543, app)
+ server.serve_forever()
diff --git a/docs/quick_tour/templating/hello_world.pt b/docs/quick_tour/templating/hello_world.pt
new file mode 100644
index 000000000..ae14f447d
--- /dev/null
+++ b/docs/quick_tour/templating/hello_world.pt
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Quick Glance</title>
+</head>
+<body>
+<h1>Hello ${name}</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/docs/quick_tour/templating/views.py b/docs/quick_tour/templating/views.py
new file mode 100644
index 000000000..90730ae32
--- /dev/null
+++ b/docs/quick_tour/templating/views.py
@@ -0,0 +1,6 @@
+from pyramid.view import view_config
+
+
+@view_config(route_name='hello', renderer='hello_world.pt')
+def hello_world(request):
+ return dict(name=request.matchdict['name'])
diff --git a/docs/quick_tour/view_classes/app.py b/docs/quick_tour/view_classes/app.py
new file mode 100644
index 000000000..40faddd00
--- /dev/null
+++ b/docs/quick_tour/view_classes/app.py
@@ -0,0 +1,13 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('hello', '/howdy/{name}')
+ config.add_route('hello_json', 'hello.json')
+ config.add_static_view(name='static', path='static')
+ config.include('pyramid_jinja2')
+ config.scan('views')
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 6543, app)
+ server.serve_forever()
diff --git a/docs/quick_tour/view_classes/delete.jinja2 b/docs/quick_tour/view_classes/delete.jinja2
new file mode 100644
index 000000000..ba45b7d16
--- /dev/null
+++ b/docs/quick_tour/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/quick_tour/view_classes/edit.jinja2 b/docs/quick_tour/view_classes/edit.jinja2
new file mode 100644
index 000000000..ce0eb5bd1
--- /dev/null
+++ b/docs/quick_tour/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/quick_tour/view_classes/hello.jinja2 b/docs/quick_tour/view_classes/hello.jinja2
new file mode 100644
index 000000000..fc3058067
--- /dev/null
+++ b/docs/quick_tour/view_classes/hello.jinja2
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>Hello World</title>
+</head>
+<body>
+<h1>Hello {{ view.name }}!</h1>
+<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>
+</body>
+</html> \ No newline at end of file
diff --git a/docs/quick_tour/view_classes/views.py b/docs/quick_tour/view_classes/views.py
new file mode 100644
index 000000000..10ff238c7
--- /dev/null
+++ b/docs/quick_tour/view_classes/views.py
@@ -0,0 +1,30 @@
+from pyramid.view import (
+ view_config,
+ view_defaults
+ )
+
+
+# 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()
diff --git a/docs/quick_tour/views/app.py b/docs/quick_tour/views/app.py
new file mode 100644
index 000000000..e8df6eff2
--- /dev/null
+++ b/docs/quick_tour/views/app.py
@@ -0,0 +1,13 @@
+from wsgiref.simple_server import make_server
+from pyramid.config import Configurator
+
+if __name__ == '__main__':
+ config = Configurator()
+ config.add_route('home', '/')
+ config.add_route('hello', '/howdy')
+ config.add_route('redirect', '/goto')
+ config.add_route('exception', '/problem')
+ config.scan('views')
+ app = config.make_wsgi_app()
+ server = make_server('0.0.0.0', 6543, app)
+ server.serve_forever()
diff --git a/docs/quick_tour/views/views.py b/docs/quick_tour/views/views.py
new file mode 100644
index 000000000..1449cbb38
--- /dev/null
+++ b/docs/quick_tour/views/views.py
@@ -0,0 +1,32 @@
+import cgi
+
+from pyramid.httpexceptions import HTTPFound
+from pyramid.response import Response
+from pyramid.view import view_config
+
+
+# First view, available at http://localhost:6543/
+@view_config(route_name='home')
+def home_view(request):
+ return Response('<p>Visit <a href="/howdy?name=lisa">hello</a></p>')
+
+
+# /howdy?name=alice which links to the next view
+@view_config(route_name='hello')
+def hello_view(request):
+ name = request.params.get('name', 'No Name')
+ body = '<p>Hi %s, this <a href="/goto">redirects</a></p>'
+ # cgi.escape to prevent Cross-Site Scripting (XSS) [CWE 79]
+ return Response(body % cgi.escape(name))
+
+
+# /goto which issues HTTP redirect to the last view
+@view_config(route_name='redirect')
+def redirect_view(request):
+ return HTTPFound(location="/problem")
+
+
+# /problem which causes a site error
+@view_config(route_name='exception')
+def exception_view(request):
+ raise Exception()