diff options
| author | Steve Piercy <web@stevepiercy.com> | 2018-08-30 04:50:53 -0700 |
|---|---|---|
| committer | Steve Piercy <web@stevepiercy.com> | 2018-08-30 04:50:53 -0700 |
| commit | 7f5a799b0a5344d5460025c05dd33e360eb9a87e (patch) | |
| tree | c9c3ecfe907389852abf99eb610664f234d0e9b0 /docs/narr/myproject | |
| parent | 33768fb147c26d93b2894a3504bcb117319a3629 (diff) | |
| download | pyramid-7f5a799b0a5344d5460025c05dd33e360eb9a87e.tar.gz pyramid-7f5a799b0a5344d5460025c05dd33e360eb9a87e.tar.bz2 pyramid-7f5a799b0a5344d5460025c05dd33e360eb9a87e.zip | |
Update narr/project.rst and /myproject starter cookiecutter source files
Diffstat (limited to 'docs/narr/myproject')
| -rw-r--r-- | docs/narr/myproject/.gitignore | 21 | ||||
| -rw-r--r-- | docs/narr/myproject/myproject/__init__.py | 9 | ||||
| -rw-r--r-- | docs/narr/myproject/myproject/routes.py | 3 | ||||
| -rw-r--r-- | docs/narr/myproject/myproject/templates/404.jinja2 | 8 | ||||
| -rw-r--r-- | docs/narr/myproject/myproject/tests.py | 2 | ||||
| -rw-r--r-- | docs/narr/myproject/myproject/views.py | 6 | ||||
| -rw-r--r-- | docs/narr/myproject/myproject/views/__init__.py | 0 | ||||
| -rw-r--r-- | docs/narr/myproject/myproject/views/default.py | 6 | ||||
| -rw-r--r-- | docs/narr/myproject/myproject/views/notfound.py | 7 | ||||
| -rw-r--r-- | docs/narr/myproject/setup.py | 2 |
10 files changed, 51 insertions, 13 deletions
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 %} +<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/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 --- /dev/null +++ b/docs/narr/myproject/myproject/views/__init__.py 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', ] |
