diff options
| author | Steve Piercy <web@stevepiercy.com> | 2019-12-28 01:46:20 -0800 |
|---|---|---|
| committer | Steve Piercy <web@stevepiercy.com> | 2020-01-02 23:30:59 -0800 |
| commit | 87e90486fb17254be7805fc6f984f43c85f3506b (patch) | |
| tree | e19fcdc11288875fc86d91fd243bfb6bb6432a56 /docs/tutorials/wiki2/basiclayout.rst | |
| parent | 0db88c72bb3c444ca0f6fbe2cda50ca02c1bc011 (diff) | |
| download | pyramid-87e90486fb17254be7805fc6f984f43c85f3506b.tar.gz pyramid-87e90486fb17254be7805fc6f984f43c85f3506b.tar.bz2 pyramid-87e90486fb17254be7805fc6f984f43c85f3506b.zip | |
Update docs/tutorials/wiki2/basiclayout.rst and related src files
Diffstat (limited to 'docs/tutorials/wiki2/basiclayout.rst')
| -rw-r--r-- | docs/tutorials/wiki2/basiclayout.rst | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index f3a9db223..ae58d80a5 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -58,16 +58,16 @@ dictionary of settings parsed from the ``.ini`` file, which contains deployment-related values, such as ``pyramid.reload_templates``, ``sqlalchemy.url``, and so on. -Next include :term:`Jinja2` templating bindings so that we can use renderers -with the ``.jinja2`` extension within our project. +Next include the package ``models`` using a dotted Python path. The exact +setup of the models will be covered later. .. literalinclude:: src/basiclayout/tutorial/__init__.py :lines: 8 :lineno-match: :language: py -Next include the package ``models`` using a dotted Python path. The exact -setup of the models will be covered later. +Next include :term:`Jinja2` templating bindings so that we can use renderers +with the ``.jinja2`` extension within our project. .. literalinclude:: src/basiclayout/tutorial/__init__.py :lines: 9 @@ -184,6 +184,25 @@ database and provide an alternate error response. That response will include the text shown at the end of the file, which will be displayed in the browser to inform the user about possible actions to take to solve the problem. +Open ``tutorial/views/notfound.py`` in the ``views`` package to look at the second view. + +.. literalinclude:: src/basiclayout/tutorial/views/notfound.py + :linenos: + :language: python + +Without repeating ourselves, we will point out the differences between this view and the previous. + +#. *Line 4*. + The ``notfound_view`` function is decorated with ``@notfound_view_config``. + This decorator registers a :term:`Not Found View` using :meth:`pyramid.config.Configurator.add_notfound_view`. + + The ``renderer`` argument names an :term:`asset specification` of ``tutorial:templates/404.jinja2``. + +#. *Lines 5-7*. + A :term:`view callable` named ``notfound_view`` is defined, which is decorated in the step above. + It sets the HTTP response status code to ``404``. + The function returns an empty dictionary to the template ``404.jinja2``, which accepts no parameters anyway. + Content models with the ``models`` package ------------------------------------------ |
