summaryrefslogtreecommitdiff
path: root/docs/quick_tour/package
diff options
context:
space:
mode:
authorSteve Piercy <web@stevepiercy.com>2018-08-30 03:40:56 -0700
committerSteve Piercy <web@stevepiercy.com>2018-08-30 03:40:56 -0700
commit8f30e87698ea2041d3baec080417167c3d2f3674 (patch)
tree7f18f1fb27b5cb6ade35f3debd325bcbd37a3d43 /docs/quick_tour/package
parent9a9ea6a2c050c1ad5044df34b49026af016c463a (diff)
downloadpyramid-8f30e87698ea2041d3baec080417167c3d2f3674.tar.gz
pyramid-8f30e87698ea2041d3baec080417167c3d2f3674.tar.bz2
pyramid-8f30e87698ea2041d3baec080417167c3d2f3674.zip
Update quick_tour with starter and alchemy cookiecutters source files
Diffstat (limited to 'docs/quick_tour/package')
-rw-r--r--docs/quick_tour/package/.gitignore21
-rw-r--r--docs/quick_tour/package/hello_world/__init__.py9
-rw-r--r--docs/quick_tour/package/hello_world/routes.py3
-rw-r--r--docs/quick_tour/package/hello_world/templates/404.jinja28
-rw-r--r--docs/quick_tour/package/hello_world/tests.py2
-rw-r--r--docs/quick_tour/package/hello_world/views/__init__.py0
-rw-r--r--docs/quick_tour/package/hello_world/views/default.py (renamed from docs/quick_tour/package/hello_world/views.py)2
-rw-r--r--docs/quick_tour/package/hello_world/views/notfound.py7
-rw-r--r--docs/quick_tour/package/setup.py2
9 files changed, 46 insertions, 8 deletions
diff --git a/docs/quick_tour/package/.gitignore b/docs/quick_tour/package/.gitignore
new file mode 100644
index 000000000..1853d983c
--- /dev/null
+++ b/docs/quick_tour/package/.gitignore
@@ -0,0 +1,21 @@
+*.egg
+*.egg-info
+*.pyc
+*$py.class
+*~
+.coverage
+coverage.xml
+build/
+dist/
+.tox/
+nosetests.xml
+env*/
+tmp/
+Data.fs*
+*.sublime-project
+*.sublime-workspace
+.*.sw?
+.sw?
+.DS_Store
+coverage
+test
diff --git a/docs/quick_tour/package/hello_world/__init__.py b/docs/quick_tour/package/hello_world/__init__.py
index 49dde36d4..a3d5a6469 100644
--- a/docs/quick_tour/package/hello_world/__init__.py
+++ b/docs/quick_tour/package/hello_world/__init__.py
@@ -4,9 +4,8 @@ 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.add_static_view('static', 'static', cache_max_age=3600)
- config.add_route('home', '/')
- config.scan()
+ with Configurator(settings=settings) as config:
+ config.include('pyramid_jinja2')
+ config.include('.routes')
+ config.scan()
return config.make_wsgi_app()
diff --git a/docs/quick_tour/package/hello_world/routes.py b/docs/quick_tour/package/hello_world/routes.py
new file mode 100644
index 000000000..25504ad4d
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/routes.py
@@ -0,0 +1,3 @@
+def includeme(config):
+ config.add_static_view('static', 'static', cache_max_age=3600)
+ config.add_route('home', '/')
diff --git a/docs/quick_tour/package/hello_world/templates/404.jinja2 b/docs/quick_tour/package/hello_world/templates/404.jinja2
new file mode 100644
index 000000000..aaf12413f
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/templates/404.jinja2
@@ -0,0 +1,8 @@
+{% extends "layout.jinja2" %}
+
+{% block content %}
+<div class="content">
+ <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter project</span></h1>
+ <p class="lead"><span class="font-semi-bold">404</span> Page Not Found</p>
+</div>
+{% endblock content %}
diff --git a/docs/quick_tour/package/hello_world/tests.py b/docs/quick_tour/package/hello_world/tests.py
index ee9745685..f01ae2a3c 100644
--- a/docs/quick_tour/package/hello_world/tests.py
+++ b/docs/quick_tour/package/hello_world/tests.py
@@ -11,7 +11,7 @@ class ViewTests(unittest.TestCase):
testing.tearDown()
def test_my_view(self):
- from .views import my_view
+ from .views.default import my_view
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info['project'], 'hello_world')
diff --git a/docs/quick_tour/package/hello_world/views/__init__.py b/docs/quick_tour/package/hello_world/views/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/views/__init__.py
diff --git a/docs/quick_tour/package/hello_world/views.py b/docs/quick_tour/package/hello_world/views/default.py
index 67f78dad7..7458da006 100644
--- a/docs/quick_tour/package/hello_world/views.py
+++ b/docs/quick_tour/package/hello_world/views/default.py
@@ -1,6 +1,6 @@
from pyramid.view import view_config
-@view_config(route_name='home', renderer='templates/mytemplate.jinja2')
+@view_config(route_name='home', renderer='../templates/mytemplate.jinja2')
def my_view(request):
return {'project': 'hello_world'}
diff --git a/docs/quick_tour/package/hello_world/views/notfound.py b/docs/quick_tour/package/hello_world/views/notfound.py
new file mode 100644
index 000000000..69d6e2804
--- /dev/null
+++ b/docs/quick_tour/package/hello_world/views/notfound.py
@@ -0,0 +1,7 @@
+from pyramid.view import notfound_view_config
+
+
+@notfound_view_config(renderer='../templates/404.jinja2')
+def notfound_view(request):
+ request.response.status = 404
+ return {}
diff --git a/docs/quick_tour/package/setup.py b/docs/quick_tour/package/setup.py
index 44d90b990..27b025384 100644
--- a/docs/quick_tour/package/setup.py
+++ b/docs/quick_tour/package/setup.py
@@ -18,7 +18,7 @@ requires = [
tests_require = [
'WebTest >= 1.3.1', # py3 compat
- 'pytest',
+ 'pytest>=3.7.4',
'pytest-cov',
]