From 7f5a799b0a5344d5460025c05dd33e360eb9a87e Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 30 Aug 2018 04:50:53 -0700 Subject: Update narr/project.rst and /myproject starter cookiecutter source files --- docs/narr/myproject/.gitignore | 21 +++++++++++++++++++++ docs/narr/myproject/myproject/__init__.py | 9 ++++----- docs/narr/myproject/myproject/routes.py | 3 +++ docs/narr/myproject/myproject/templates/404.jinja2 | 8 ++++++++ docs/narr/myproject/myproject/tests.py | 2 +- docs/narr/myproject/myproject/views.py | 6 ------ docs/narr/myproject/myproject/views/__init__.py | 0 docs/narr/myproject/myproject/views/default.py | 6 ++++++ docs/narr/myproject/myproject/views/notfound.py | 7 +++++++ docs/narr/myproject/setup.py | 2 +- 10 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 docs/narr/myproject/.gitignore create mode 100644 docs/narr/myproject/myproject/routes.py create mode 100644 docs/narr/myproject/myproject/templates/404.jinja2 delete mode 100644 docs/narr/myproject/myproject/views.py create mode 100644 docs/narr/myproject/myproject/views/__init__.py create mode 100644 docs/narr/myproject/myproject/views/default.py create mode 100644 docs/narr/myproject/myproject/views/notfound.py (limited to 'docs/narr/myproject') diff --git a/docs/narr/myproject/.gitignore b/docs/narr/myproject/.gitignore new file mode 100644 index 000000000..1853d983c --- /dev/null +++ b/docs/narr/myproject/.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/narr/myproject/myproject/__init__.py b/docs/narr/myproject/myproject/__init__.py index 49dde36d4..a3d5a6469 100644 --- a/docs/narr/myproject/myproject/__init__.py +++ b/docs/narr/myproject/myproject/__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/narr/myproject/myproject/routes.py b/docs/narr/myproject/myproject/routes.py new file mode 100644 index 000000000..25504ad4d --- /dev/null +++ b/docs/narr/myproject/myproject/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/narr/myproject/myproject/templates/404.jinja2 b/docs/narr/myproject/myproject/templates/404.jinja2 new file mode 100644 index 000000000..aaf12413f --- /dev/null +++ b/docs/narr/myproject/myproject/templates/404.jinja2 @@ -0,0 +1,8 @@ +{% extends "layout.jinja2" %} + +{% block content %} +
+

Pyramid Starter project

+

404 Page Not Found

+
+{% endblock content %} diff --git a/docs/narr/myproject/myproject/tests.py b/docs/narr/myproject/myproject/tests.py index fd414cced..05ccadcfb 100644 --- a/docs/narr/myproject/myproject/tests.py +++ b/docs/narr/myproject/myproject/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'], 'MyProject') diff --git a/docs/narr/myproject/myproject/views.py b/docs/narr/myproject/myproject/views.py deleted file mode 100644 index 9e9ec4320..000000000 --- a/docs/narr/myproject/myproject/views.py +++ /dev/null @@ -1,6 +0,0 @@ -from pyramid.view import view_config - - -@view_config(route_name='home', renderer='templates/mytemplate.jinja2') -def my_view(request): - return {'project': 'MyProject'} diff --git a/docs/narr/myproject/myproject/views/__init__.py b/docs/narr/myproject/myproject/views/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/narr/myproject/myproject/views/default.py b/docs/narr/myproject/myproject/views/default.py new file mode 100644 index 000000000..8324cfe32 --- /dev/null +++ b/docs/narr/myproject/myproject/views/default.py @@ -0,0 +1,6 @@ +from pyramid.view import view_config + + +@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +def my_view(request): + return {'project': 'myproject'} diff --git a/docs/narr/myproject/myproject/views/notfound.py b/docs/narr/myproject/myproject/views/notfound.py new file mode 100644 index 000000000..69d6e2804 --- /dev/null +++ b/docs/narr/myproject/myproject/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/narr/myproject/setup.py b/docs/narr/myproject/setup.py index 153a659ba..cf626880f 100644 --- a/docs/narr/myproject/setup.py +++ b/docs/narr/myproject/setup.py @@ -18,7 +18,7 @@ requires = [ tests_require = [ 'WebTest >= 1.3.1', # py3 compat - 'pytest', + 'pytest>=3.7.4', 'pytest-cov', ] -- cgit v1.2.3