diff options
| author | Steve Piercy <web@stevepiercy.com> | 2018-08-30 03:49:21 -0700 |
|---|---|---|
| committer | Steve Piercy <web@stevepiercy.com> | 2018-08-30 03:49:21 -0700 |
| commit | 33768fb147c26d93b2894a3504bcb117319a3629 (patch) | |
| tree | 225d50ffca43cd7e98221f048fb245c36230f57a /docs/quick_tutorial | |
| parent | 8f30e87698ea2041d3baec080417167c3d2f3674 (diff) | |
| download | pyramid-33768fb147c26d93b2894a3504bcb117319a3629.tar.gz pyramid-33768fb147c26d93b2894a3504bcb117319a3629.tar.bz2 pyramid-33768fb147c26d93b2894a3504bcb117319a3629.zip | |
Update quick_tutorial with starter cookiecutter source files
Diffstat (limited to 'docs/quick_tutorial')
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/.gitignore | 21 | ||||
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/cc_starter/__init__.py | 9 | ||||
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/cc_starter/routes.py | 3 | ||||
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/cc_starter/templates/404.jinja2 | 8 | ||||
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/cc_starter/tests.py | 2 | ||||
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/cc_starter/views/__init__.py | 0 | ||||
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/cc_starter/views/default.py (renamed from docs/quick_tutorial/cookiecutters/cc_starter/views.py) | 2 | ||||
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py | 7 | ||||
| -rw-r--r-- | docs/quick_tutorial/cookiecutters/setup.py | 5 |
9 files changed, 48 insertions, 9 deletions
diff --git a/docs/quick_tutorial/cookiecutters/.gitignore b/docs/quick_tutorial/cookiecutters/.gitignore new file mode 100644 index 000000000..1853d983c --- /dev/null +++ b/docs/quick_tutorial/cookiecutters/.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_tutorial/cookiecutters/cc_starter/__init__.py b/docs/quick_tutorial/cookiecutters/cc_starter/__init__.py index 49dde36d4..a3d5a6469 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/__init__.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/__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_tutorial/cookiecutters/cc_starter/routes.py b/docs/quick_tutorial/cookiecutters/cc_starter/routes.py new file mode 100644 index 000000000..25504ad4d --- /dev/null +++ b/docs/quick_tutorial/cookiecutters/cc_starter/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_tutorial/cookiecutters/cc_starter/templates/404.jinja2 b/docs/quick_tutorial/cookiecutters/cc_starter/templates/404.jinja2 new file mode 100644 index 000000000..aaf12413f --- /dev/null +++ b/docs/quick_tutorial/cookiecutters/cc_starter/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_tutorial/cookiecutters/cc_starter/tests.py b/docs/quick_tutorial/cookiecutters/cc_starter/tests.py index 2f553bbb4..f3886be84 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/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'], 'cc_starter') diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/views/__init__.py b/docs/quick_tutorial/cookiecutters/cc_starter/views/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/docs/quick_tutorial/cookiecutters/cc_starter/views/__init__.py diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/views.py b/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py index deedd53b8..47af359b5 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/views.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/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': 'cc_starter'} diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py b/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py new file mode 100644 index 000000000..69d6e2804 --- /dev/null +++ b/docs/quick_tutorial/cookiecutters/cc_starter/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_tutorial/cookiecutters/setup.py b/docs/quick_tutorial/cookiecutters/setup.py index 0d1b3f70e..9482e7c32 100644 --- a/docs/quick_tutorial/cookiecutters/setup.py +++ b/docs/quick_tutorial/cookiecutters/setup.py @@ -9,15 +9,16 @@ with open(os.path.join(here, 'CHANGES.txt')) as f: CHANGES = f.read() requires = [ + 'plaster_pastedeploy', 'pyramid', - 'pyramid_debugtoolbar', 'pyramid_jinja2', + 'pyramid_debugtoolbar', 'waitress', ] tests_require = [ 'WebTest >= 1.3.1', # py3 compat - 'pytest', + 'pytest>=3.7.4', 'pytest-cov', ] |
