Steve Piercy
2018-08-30 332ca33fc51fb64b8e15e1aceb28e96dee2c6fec
Merge pull request #3338 from Pylons/docs-cc-update-for-1.10

Update docs for all cookiecutters
5 files deleted
53 files added
88 files modified
2 files renamed
1431 ■■■■ changed files
docs/narr/myproject/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/narr/myproject/myproject/__init__.py 9 ●●●●● patch | view | raw | blame | history
docs/narr/myproject/myproject/routes.py 3 ●●●●● patch | view | raw | blame | history
docs/narr/myproject/myproject/templates/404.jinja2 8 ●●●●● patch | view | raw | blame | history
docs/narr/myproject/myproject/tests.py 2 ●●● patch | view | raw | blame | history
docs/narr/myproject/myproject/views.py 6 ●●●●● patch | view | raw | blame | history
docs/narr/myproject/myproject/views/__init__.py patch | view | raw | blame | history
docs/narr/myproject/myproject/views/default.py 6 ●●●●● patch | view | raw | blame | history
docs/narr/myproject/myproject/views/notfound.py 7 ●●●●● patch | view | raw | blame | history
docs/narr/myproject/setup.py 2 ●●● patch | view | raw | blame | history
docs/narr/project.rst 122 ●●●●● patch | view | raw | blame | history
docs/narr/testing.rst 4 ●●●● patch | view | raw | blame | history
docs/quick_tour.rst 8 ●●●● patch | view | raw | blame | history
docs/quick_tour/logging/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/quick_tour/logging/hello_world/__init__.py 9 ●●●●● patch | view | raw | blame | history
docs/quick_tour/logging/hello_world/routes.py 3 ●●●●● patch | view | raw | blame | history
docs/quick_tour/logging/hello_world/templates/404.jinja2 8 ●●●●● patch | view | raw | blame | history
docs/quick_tour/logging/hello_world/tests.py 2 ●●● patch | view | raw | blame | history
docs/quick_tour/logging/hello_world/views/__init__.py patch | view | raw | blame | history
docs/quick_tour/logging/hello_world/views/default.py 2 ●●● patch | view | raw | blame | history
docs/quick_tour/logging/hello_world/views/notfound.py 7 ●●●●● patch | view | raw | blame | history
docs/quick_tour/logging/setup.py 2 ●●● patch | view | raw | blame | history
docs/quick_tour/package/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/quick_tour/package/hello_world/__init__.py 9 ●●●●● patch | view | raw | blame | history
docs/quick_tour/package/hello_world/routes.py 3 ●●●●● patch | view | raw | blame | history
docs/quick_tour/package/hello_world/templates/404.jinja2 8 ●●●●● patch | view | raw | blame | history
docs/quick_tour/package/hello_world/tests.py 2 ●●● patch | view | raw | blame | history
docs/quick_tour/package/hello_world/views.py 6 ●●●●● patch | view | raw | blame | history
docs/quick_tour/package/hello_world/views/__init__.py patch | view | raw | blame | history
docs/quick_tour/package/hello_world/views/default.py 6 ●●●●● patch | view | raw | blame | history
docs/quick_tour/package/hello_world/views/notfound.py 7 ●●●●● patch | view | raw | blame | history
docs/quick_tour/package/setup.py 2 ●●● patch | view | raw | blame | history
docs/quick_tour/sessions/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sessions/hello_world/__init__.py 13 ●●●● patch | view | raw | blame | history
docs/quick_tour/sessions/hello_world/routes.py 3 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sessions/hello_world/templates/404.jinja2 8 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sessions/hello_world/tests.py 2 ●●● patch | view | raw | blame | history
docs/quick_tour/sessions/hello_world/views/__init__.py patch | view | raw | blame | history
docs/quick_tour/sessions/hello_world/views/default.py 2 ●●● patch | view | raw | blame | history
docs/quick_tour/sessions/hello_world/views/notfound.py 7 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sessions/setup.py 2 ●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/README.txt 12 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/development.ini 11 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/production.ini 9 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/pytest.ini 2 ●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/setup.py 7 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/__init__.py 10 ●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/alembic/env.py 58 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako 24 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt 1 ●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/pshell.py 12 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/scripts/initialize_db.py 48 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/scripts/initializedb.py 45 ●●●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 2 ●●● patch | view | raw | blame | history
docs/quick_tour/sqla_demo/sqla_demo/views/default.py 11 ●●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/cc_starter/__init__.py 9 ●●●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/cc_starter/routes.py 3 ●●●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/cc_starter/templates/404.jinja2 8 ●●●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/cc_starter/tests.py 2 ●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/cc_starter/views.py 6 ●●●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/cc_starter/views/__init__.py patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/cc_starter/views/default.py 6 ●●●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py 7 ●●●●● patch | view | raw | blame | history
docs/quick_tutorial/cookiecutters/setup.py 5 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/authorization.rst 6 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/authorization/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/authorization/README.txt 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/authorization/development.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/authorization/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/authorization/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/authorization/tutorial/pshell.py 11 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/authorization/tutorial/templates/edit.pt 1 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/authorization/tutorial/templates/view.pt 1 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/basiclayout/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/basiclayout/development.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/basiclayout/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/basiclayout/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/basiclayout/tutorial/pshell.py 11 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/installation/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/installation/development.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/installation/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/installation/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/installation/tutorial/pshell.py 11 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/models/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/models/development.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/models/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/models/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/models/tutorial/pshell.py 11 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/README.txt 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/development.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/tutorial/pshell.py 11 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/tutorial/templates/edit.pt 1 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/tutorial/templates/mytemplate.pt 67 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/tests/tutorial/templates/view.pt 1 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/views/.gitignore 21 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/views/README.txt 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/views/development.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/views/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/views/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki/src/views/tutorial/pshell.py 11 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/basiclayout.rst 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authentication/development.ini 5 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authentication/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authentication/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authentication/tutorial/__init__.py 12 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authentication/tutorial/pshell.py 12 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authentication/tutorial/scripts/initialize_db.py 22 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authorization/development.ini 5 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authorization/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authorization/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authorization/tutorial/__init__.py 12 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authorization/tutorial/pshell.py 12 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/authorization/tutorial/scripts/initialize_db.py 22 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/basiclayout/development.ini 5 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/basiclayout/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/basiclayout/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py 10 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/basiclayout/tutorial/pshell.py 12 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/basiclayout/tutorial/scripts/initialize_db.py 26 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/installation/development.ini 5 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/installation/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/installation/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/installation/tutorial/__init__.py 10 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/installation/tutorial/pshell.py 12 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/installation/tutorial/scripts/initialize_db.py 26 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/models/development.ini 5 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/models/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/models/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/models/tutorial/__init__.py 10 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/models/tutorial/pshell.py 12 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/models/tutorial/scripts/initialize_db.py 22 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/tests/development.ini 5 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/tests/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/tests/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/tests/tutorial/__init__.py 12 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/tests/tutorial/pshell.py 12 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/tests/tutorial/scripts/initialize_db.py 22 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/views/development.ini 5 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/views/production.ini 3 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/views/setup.py 2 ●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/views/tutorial/__init__.py 10 ●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/views/tutorial/pshell.py 12 ●●●●● patch | view | raw | blame | history
docs/tutorials/wiki2/src/views/tutorial/scripts/initialize_db.py 22 ●●●● patch | view | raw | blame | history
docs/narr/myproject/.gitignore
New file
@@ -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
docs/narr/myproject/myproject/__init__.py
@@ -4,9 +4,8 @@
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()
docs/narr/myproject/myproject/routes.py
New file
@@ -0,0 +1,3 @@
def includeme(config):
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
docs/narr/myproject/myproject/templates/404.jinja2
New file
@@ -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 %}
docs/narr/myproject/myproject/tests.py
@@ -11,7 +11,7 @@
        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')
docs/narr/myproject/myproject/views.py
File was deleted
docs/narr/myproject/myproject/views/__init__.py
docs/narr/myproject/myproject/views/default.py
New file
@@ -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'}
docs/narr/myproject/myproject/views/notfound.py
New file
@@ -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 {}
docs/narr/myproject/setup.py
@@ -18,7 +18,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/narr/project.rst
@@ -525,21 +525,27 @@
.. code-block:: text
    myproject/
    myproject
    â”œâ”€â”€ .coveragerc
    â”œâ”€â”€ .gitignore
    â”œâ”€â”€ CHANGES.txt
    â”œâ”€â”€ MANIFEST.in
    â”œâ”€â”€ myproject
    â”‚   â”œâ”€â”€ __init__.py
    â”‚   â”œâ”€â”€ routes.py
    â”‚   â”œâ”€â”€ static
    â”‚   â”‚   â”œâ”€â”€ pyramid-16x16.png
    â”‚   â”‚   â”œâ”€â”€ pyramid.png
    â”‚   â”‚   â””── theme.css
    â”‚   â”œâ”€â”€ templates
    â”‚   â”‚   â”œâ”€â”€ 404.jinja2
    â”‚   â”‚   â”œâ”€â”€ layout.jinja2
    â”‚   â”‚   â””── mytemplate.jinja2
    â”‚   â”œâ”€â”€ tests.py
    â”‚   â””── views.py
    â”‚   â””── views
    â”‚       â”œâ”€â”€ __init__.py
    â”‚       â”œâ”€â”€ default.py
    â”‚       â””── notfound.py
    â”œâ”€â”€ README.txt
    â”œâ”€â”€ development.ini
    â”œâ”€â”€ production.ini
@@ -556,6 +562,8 @@
describe, run, and test your application.
#. ``.coveragerc`` configures coverage when running tests.
#. ``.gitignore`` tells git which files and directories to ignore from source code version control.
#. ``CHANGES.txt`` describes the changes you've made to the application.  It is
   conventionally written in :term:`reStructuredText` format.
@@ -810,7 +818,9 @@
#. A ``tests.py`` module, which contains unit test code for the application.
#. A ``views.py`` module, which contains view code for the application.
#. A ``views`` package, which contains view code for the application.
#. A ``static`` directory, which contains static files, including images and CSS.
These are purely conventions established by the cookiecutter. :app:`Pyramid`
doesn't insist that you name things in any particular way. However, it's
@@ -848,31 +858,53 @@
   Line 8 adds support for Jinja2 templating bindings, allowing us to
   specify renderers with the ``.jinja2`` extension.
   Line 9 registers a static view, which will serve up the files from the
   ``myproject:static`` :term:`asset specification` (the ``static`` directory
   of the ``myproject`` package).
   Line 9 includes the ``routes.py`` module.
   Line 10 adds a :term:`route` to the configuration.  This route is later used
   by a view in the ``views`` module.
   Line 11 calls ``config.scan()``, which picks up view registrations declared
   Line 10 calls ``config.scan()``, which picks up view registrations declared
   elsewhere in the package (in this case, in the ``views.py`` module).
   Line 12 returns a :term:`WSGI` application to the caller of the function
   Line 11 returns a :term:`WSGI` application to the caller of the function
   (Pyramid's pserve).
.. index::
    single: routes.py
.. _routes_py:
``routes.py``
~~~~~~~~~~~~~
The ``routes.py`` module gets included by the ``main`` function in our ``__init__.py``.
It registers a view and a route.
.. literalinclude:: myproject/myproject/routes.py
    :language: python
    :linenos:
Line 2 registers a static view, which will serve up the files from the ``myproject:static`` :term:`asset specification` (the ``static`` directory of the ``myproject`` package).
Line 3 adds a :term:`route` to the configuration.  This route is later used by a view in the ``views`` module.
.. index::
   single: views.py
``views.py``
~~~~~~~~~~~~
``views`` package
~~~~~~~~~~~~~~~~~
Much of the heavy lifting in a :app:`Pyramid` application is done by *view
callables*.  A :term:`view callable` is the main tool of a :app:`Pyramid` web
application developer; it is a bit of code which accepts a :term:`request` and
which returns a :term:`response`.
.. literalinclude:: myproject/myproject/views.py
Our project has a ``views`` package by virtue of it being a directory containing an ``__init__.py`` file.
This ``__init__.py`` file happens to have no content, although it could as a project develops.
We have two view modules in the ``views`` package.
Let's look at ``default.py``.
.. literalinclude:: myproject/myproject/views/default.py
   :language: python
   :linenos:
@@ -880,17 +912,17 @@
function named ``my_view`` is decorated with a ``view_config`` decorator (which
is processed by the ``config.scan()`` line in our ``__init__.py``). The
view_config decorator asserts that this view be found when a :term:`route`
named ``home`` is matched.  In our case, because our ``__init__.py`` maps the
named ``home`` is matched.  In our case, because our ``routes.py`` maps the
route named ``home`` to the URL pattern ``/``, this route will match when a
visitor visits the root URL.  The view_config decorator also names a
``renderer``, which in this case is a template that will be used to render the
result of the view callable.  This particular view declaration points at
``templates/mytemplate.pt``, which is an :term:`asset specification` that
specifies the ``mytemplate.pt`` file within the ``templates`` directory of the
``../templates/mytemplate.jinja2``, which is an :term:`asset specification` that
specifies the ``mytemplate.jinja2`` file within the ``templates`` directory of the
``myproject`` package.  The asset specification could have also been specified
as ``myproject:templates/mytemplate.pt``; the leading package name and colon is
as ``myproject:templates/mytemplate.jinja2``; the leading package name and colon is
optional.  The template file pointed to is a :term:`Jinja2` template
file (``templates/my_template.jinja2``).
file (``templates/mytemplate.jinja2``).
This view callable function is handed a single piece of information: the
:term:`request`.  The *request* is an instance of the :term:`WebOb` ``Request``
@@ -902,6 +934,15 @@
the HTML in a :term:`response`.
.. note:: Dictionaries provide values to :term:`template`\s.
Now let's look at ``notfound.py``.
.. literalinclude:: myproject/myproject/views/notfound.py
   :language: python
   :linenos:
This file is similar to ``default.py``.
It merely returns a ``404`` response status and an empty dictionary to the template at ``../templates/404.jinja2``.
.. note:: When the application is run with the cookiecutter's :ref:`default
   development.ini <myproject_ini>` configuration, :ref:`logging is set up
@@ -964,7 +1005,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is the content :term:`Jinja2` template that exists in the project.  It is referenced by the call to ``@view_config`` as the ``renderer``
of the ``my_view`` view callable in the ``views.py`` file.  See
of the ``my_view`` view callable in the ``views/default.py`` file.  See
:ref:`views_which_use_a_renderer` for more information about renderers. It inherits ("extends") the HTML provided by ``layout.jinja2``, replacing the content block with its own content.
.. literalinclude:: myproject/myproject/templates/mytemplate.jinja2
@@ -974,6 +1015,18 @@
Templates are accessed and used by view configurations and sometimes by view
functions themselves.  See :ref:`templates_used_directly` and
:ref:`templates_used_as_renderers`.
``templates/404.jinja2``
~~~~~~~~~~~~~~~~~~~~~~~~
This template is similar to ``mytemplate.jinja2``, but with a few differences.
It is referenced by the call to ``@notfound_view_config`` as the ``renderer`` of the ``notfound_view`` view callable in the ``views/notfound.py`` file.
It inherits the HTML provided by ``layout.jinja2``, replacing the content block with its own content.
.. literalinclude:: myproject/myproject/templates/404.jinja2
   :language: jinja
   :linenos:
.. index::
@@ -1015,32 +1068,11 @@
For example, the configuration method named
:meth:`~pyramid.config.Configurator.add_view` requires you to pass a
:term:`dotted Python name` or a direct object reference as the class or
function to be used as a view.  By default, the ``starter`` cookiecutter would have
you add view functions to the ``views.py`` module in your package. However, you
might be more comfortable creating a ``views`` *directory*, and adding a single
file for each view.
function to be used as a view.
By default, the ``starter`` cookiecutter would have you create a ``views`` directory, and add a single file for each view or collection of related views.
However, you might be more comfortable creating a single ``views.py`` module in your package and add view functions to it.
If your project package name was ``myproject`` and you wanted to arrange all
your views in a Python subpackage within the ``myproject`` :term:`package`
named ``views`` instead of within a single ``views.py`` file, you might do the
following.
- Create a ``views`` directory inside your ``myproject`` package directory (the
  same directory which holds ``views.py``).
- Create a file within the new ``views`` directory named ``__init__.py``.  (It
  can be empty.  This just tells Python that the ``views`` directory is a
  *package*.)
- *Move* the content from the existing ``views.py`` file to a file inside the
  new ``views`` directory named, say, ``blog.py``.  Because the ``templates``
  directory remains in the ``myproject`` package, the template :term:`asset
  specification` values in ``blog.py`` must now be fully qualified with the
  project's package name (``myproject:templates/blog.pt``).
You can then continue to add view callable functions to the ``blog.py`` module,
but you can also add other ``.py`` files which contain view callable functions
to the ``views`` directory.  As long as you use the ``@view_config`` directive
Whatever structure you prefer, as long as you use the ``@view_config`` directive
to register views in conjunction with ``config.scan()``, they will be picked up
automatically when the application is restarted.
docs/narr/testing.rst
@@ -396,10 +396,10 @@
    $VENV/bin/pip install -e ".[testing]"
In your ``MyPackage`` project, your :term:`package` is named ``myproject``
which contains a ``views`` module, which in turn contains a :term:`view`
which contains a ``views`` package containing a ``default.py`` module, which in turn contains a :term:`view`
function ``my_view`` that returns an HTML body when the root URL is invoked:
   .. literalinclude:: myproject/myproject/views.py
   .. literalinclude:: myproject/myproject/views/default.py
      :linenos:
      :language: python
docs/quick_tour.rst
@@ -755,14 +755,14 @@
Maybe you would like to log messages in your code? In your Python module,
import and set up the logging in your ``views.py``:
.. literalinclude:: quick_tour/logging/hello_world/views.py
.. literalinclude:: quick_tour/logging/hello_world/views/default.py
    :language: python
    :lineno-match:
    :lines: 3-4
You can now, in your code, log messages:
.. literalinclude:: quick_tour/logging/hello_world/views.py
.. literalinclude:: quick_tour/logging/hello_world/views/default.py
    :language: python
    :lineno-match:
    :lines: 7-8
@@ -819,13 +819,13 @@
.. literalinclude:: quick_tour/sessions/hello_world/__init__.py
    :language: python
    :lineno-match:
    :lines: 10-13
    :lines: 9-12
    :emphasize-lines: 2-3
Pyramid's :term:`request` object now has a ``session`` attribute that we can
use in our view code in ``views.py``:
.. literalinclude:: quick_tour/sessions/hello_world/views.py
.. literalinclude:: quick_tour/sessions/hello_world/views/default.py
    :language: python
    :lineno-match:
    :lines: 7-
docs/quick_tour/logging/.gitignore
New file
@@ -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
docs/quick_tour/logging/hello_world/__init__.py
@@ -4,9 +4,8 @@
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()
docs/quick_tour/logging/hello_world/routes.py
New file
@@ -0,0 +1,3 @@
def includeme(config):
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
docs/quick_tour/logging/hello_world/templates/404.jinja2
New file
@@ -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 %}
docs/quick_tour/logging/hello_world/tests.py
@@ -11,7 +11,7 @@
        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')
docs/quick_tour/logging/hello_world/views/__init__.py
docs/quick_tour/logging/hello_world/views/default.py
File was renamed from docs/quick_tour/logging/hello_world/views.py
@@ -3,7 +3,7 @@
import logging
log = logging.getLogger(__name__)
@view_config(route_name='home', renderer='templates/mytemplate.jinja2')
@view_config(route_name='home', renderer='../templates/mytemplate.jinja2')
def my_view(request):
    log.debug('Some Message')
    return {'project': 'hello_world'}
docs/quick_tour/logging/hello_world/views/notfound.py
New file
@@ -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 {}
docs/quick_tour/logging/setup.py
@@ -18,7 +18,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/quick_tour/package/.gitignore
New file
@@ -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
docs/quick_tour/package/hello_world/__init__.py
@@ -4,9 +4,8 @@
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()
docs/quick_tour/package/hello_world/routes.py
New file
@@ -0,0 +1,3 @@
def includeme(config):
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
docs/quick_tour/package/hello_world/templates/404.jinja2
New file
@@ -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 %}
docs/quick_tour/package/hello_world/tests.py
@@ -11,7 +11,7 @@
        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')
docs/quick_tour/package/hello_world/views.py
File was deleted
docs/quick_tour/package/hello_world/views/__init__.py
docs/quick_tour/package/hello_world/views/default.py
New file
@@ -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': 'hello_world'}
docs/quick_tour/package/hello_world/views/notfound.py
New file
@@ -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 {}
docs/quick_tour/package/setup.py
@@ -18,7 +18,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/quick_tour/sessions/.gitignore
New file
@@ -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
docs/quick_tour/sessions/hello_world/__init__.py
@@ -4,11 +4,10 @@
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', '/')
    my_session_factory = SignedCookieSessionFactory('itsaseekreet')
    config.set_session_factory(my_session_factory)
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.routes')
        my_session_factory = SignedCookieSessionFactory('itsaseekreet')
        config.set_session_factory(my_session_factory)
        config.scan()
    return config.make_wsgi_app()
docs/quick_tour/sessions/hello_world/routes.py
New file
@@ -0,0 +1,3 @@
def includeme(config):
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
docs/quick_tour/sessions/hello_world/templates/404.jinja2
New file
@@ -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 %}
docs/quick_tour/sessions/hello_world/tests.py
@@ -11,7 +11,7 @@
        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')
docs/quick_tour/sessions/hello_world/views/__init__.py
docs/quick_tour/sessions/hello_world/views/default.py
File was renamed from docs/quick_tour/sessions/hello_world/views.py
@@ -3,7 +3,7 @@
import logging
log = logging.getLogger(__name__)
@view_config(route_name='home', renderer='templates/mytemplate.jinja2')
@view_config(route_name='home', renderer='../templates/mytemplate.jinja2')
def my_view(request):
    log.debug('Some Message')
    session = request.session
docs/quick_tour/sessions/hello_world/views/notfound.py
New file
@@ -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 {}
docs/quick_tour/sessions/setup.py
@@ -18,7 +18,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/quick_tour/sqla_demo/.gitignore
New file
@@ -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
docs/quick_tour/sqla_demo/README.txt
@@ -20,7 +20,17 @@
    env/bin/pip install -e ".[testing]"
- Configure the database.
- Initialize and upgrade the database using Alembic.
    - Generate your first revision.
        env/bin/alembic -c development.ini revision --autogenerate -m "init"
    - Upgrade to that revision.
        env/bin/alembic -c development.ini upgrade head
- Load default data into the database using a script.
    env/bin/initialize_sqla_demo_db development.ini
docs/quick_tour/sqla_demo/development.ini
@@ -22,9 +22,18 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = sqla_demo.pshell.setup
###
# wsgi server configuration
###
[alembic]
# path to migration scripts
script_location = sqla_demo/alembic
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s
# file_template = %%(rev)s_%%(slug)s
[server:main]
use = egg:waitress#main
@@ -54,7 +63,7 @@
qualname = sqla_demo
[logger_sqlalchemy]
level = INFO
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
docs/quick_tour/sqla_demo/production.ini
@@ -16,10 +16,19 @@
retry.attempts = 3
[pshell]
setup = sqla_demo.pshell.setup
###
# wsgi server configuration
###
[alembic]
# path to migration scripts
script_location = sqla_demo/alembic
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s
# file_template = %%(rev)s_%%(slug)s
[server:main]
use = egg:waitress#main
listen = *:6543
docs/quick_tour/sqla_demo/pytest.ini
@@ -1,3 +1,3 @@
[pytest]
testpaths = sqla_demo
python_files = *.py
python_files = test*.py
docs/quick_tour/sqla_demo/setup.py
@@ -9,8 +9,9 @@
    CHANGES = f.read()
requires = [
    'alembic',
    'plaster_pastedeploy',
    'pyramid >= 1.9a',
    'pyramid >= 1.9',
    'pyramid_debugtoolbar',
    'pyramid_jinja2',
    'pyramid_retry',
@@ -23,7 +24,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
@@ -54,7 +55,7 @@
            'main = sqla_demo:main',
        ],
        'console_scripts': [
            'initialize_sqla_demo_db = sqla_demo.scripts.initializedb:main',
            'initialize_sqla_demo_db = sqla_demo.scripts.initialize_db:main',
        ],
    },
)
docs/quick_tour/sqla_demo/sqla_demo/__init__.py
@@ -4,9 +4,9 @@
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.models')
        config.include('.routes')
        config.scan()
    return config.make_wsgi_app()
docs/quick_tour/sqla_demo/sqla_demo/alembic/env.py
New file
@@ -0,0 +1,58 @@
"""Pyramid bootstrap environment. """
from alembic import context
from pyramid.paster import get_appsettings, setup_logging
from sqlalchemy import engine_from_config
from sqla_demo.models.meta import Base
config = context.config
setup_logging(config.config_file_name)
settings = get_appsettings(config.config_file_name)
target_metadata = Base.metadata
def run_migrations_offline():
    """Run migrations in 'offline' mode.
    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.
    Calls to context.execute() here emit the given string to the
    script output.
    """
    context.configure(url=settings['sqlalchemy.url'])
    with context.begin_transaction():
        context.run_migrations()
def run_migrations_online():
    """Run migrations in 'online' mode.
    In this scenario we need to create an Engine
    and associate a connection with the context.
    """
    engine = engine_from_config(settings, prefix='sqlalchemy.')
    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata
    )
    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
if context.is_offline_mode():
    run_migrations_offline()
else:
    run_migrations_online()
docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako
New file
@@ -0,0 +1,24 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade():
    ${upgrades if upgrades else "pass"}
def downgrade():
    ${downgrades if downgrades else "pass"}
docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt
New file
@@ -0,0 +1 @@
Placeholder for alembic versions
docs/quick_tour/sqla_demo/sqla_demo/pshell.py
New file
@@ -0,0 +1,12 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['dbsession'] = request.dbsession
    env['models'] = models
docs/quick_tour/sqla_demo/sqla_demo/scripts/initialize_db.py
New file
@@ -0,0 +1,48 @@
import argparse
import sys
from pyramid.paster import bootstrap, setup_logging
from sqlalchemy.exc import OperationalError
from .. import models
def setup_models(dbsession):
    """
    Add or update models / fixtures in the database.
    """
    model = models.mymodel.MyModel(name='one', value=1)
    dbsession.add(model)
def parse_args(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'config_uri',
        help='Configuration file, e.g., development.ini',
    )
    return parser.parse_args(argv[1:])
def main(argv=sys.argv):
    args = parse_args(argv)
    setup_logging(args.config_uri)
    env = bootstrap(args.config_uri)
    try:
        with env['request'].tm:
            dbsession = env['request'].dbsession
            setup_models(dbsession)
    except OperationalError:
        print('''
Pyramid is having a problem using your SQL database.  The problem
might be caused by one of the following things:
1.  You may need to initialize your database tables with `alembic`.
    Check your README.txt for description and try to run it.
2.  Your database server may not be running.  Check that the
    database server referred to by the "sqlalchemy.url" setting in
    your "development.ini" file is running.
            ''')
docs/quick_tour/sqla_demo/sqla_demo/scripts/initializedb.py
File was deleted
docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2
@@ -5,4 +5,4 @@
  <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy project</span></h1>
  <p class="lead">Welcome to <span class="font-normal">{{project}}</span>, a&nbsp;Pyramid application generated&nbsp;by<br><span class="font-normal">Cookiecutter</span>.</p>
</div>
{% endblock content %}
{% endblock content %}
docs/quick_tour/sqla_demo/sqla_demo/views/default.py
@@ -3,14 +3,14 @@
from sqlalchemy.exc import DBAPIError
from ..models import MyModel
from .. import models
@view_config(route_name='home', renderer='../templates/mytemplate.jinja2')
def my_view(request):
    try:
        query = request.dbsession.query(MyModel)
        one = query.filter(MyModel.name == 'one').first()
        query = request.dbsession.query(models.MyModel)
        one = query.filter(models.MyModel.name == 'one').first()
    except DBAPIError:
        return Response(db_err_msg, content_type='text/plain', status=500)
    return {'one': one, 'project': 'sqla_demo'}
@@ -20,9 +20,8 @@
Pyramid is having a problem using your SQL database.  The problem
might be caused by one of the following things:
1.  You may need to run the "initialize_sqla_demo_db" script
    to initialize your database tables.  Check your virtual
    environment's "bin" directory for this script and try to run it.
1.  You may need to initialize your database tables with `alembic`.
    Check your README.txt for description and try to run it.
2.  Your database server may not be running.  Check that the
    database server referred to by the "sqlalchemy.url" setting in
docs/quick_tutorial/cookiecutters/.gitignore
New file
@@ -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
docs/quick_tutorial/cookiecutters/cc_starter/__init__.py
@@ -4,9 +4,8 @@
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()
docs/quick_tutorial/cookiecutters/cc_starter/routes.py
New file
@@ -0,0 +1,3 @@
def includeme(config):
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
docs/quick_tutorial/cookiecutters/cc_starter/templates/404.jinja2
New file
@@ -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 %}
docs/quick_tutorial/cookiecutters/cc_starter/tests.py
@@ -11,7 +11,7 @@
        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')
docs/quick_tutorial/cookiecutters/cc_starter/views.py
File was deleted
docs/quick_tutorial/cookiecutters/cc_starter/views/__init__.py
docs/quick_tutorial/cookiecutters/cc_starter/views/default.py
New file
@@ -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': 'cc_starter'}
docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py
New file
@@ -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 {}
docs/quick_tutorial/cookiecutters/setup.py
@@ -9,15 +9,16 @@
    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',
]
docs/tutorials/wiki/authorization.rst
@@ -312,7 +312,7 @@
.. literalinclude:: src/authorization/tutorial/templates/edit.pt
   :lines: 35-39
   :emphasize-lines: 3-5
   :emphasize-lines: 2-4
   :language: html
The attribute ``tal:condition="logged_in"`` will make the element be included
@@ -355,7 +355,7 @@
.. literalinclude:: src/authorization/tutorial/templates/edit.pt
   :linenos:
   :emphasize-lines: 37-39
   :emphasize-lines: 36-38
   :language: html
Only the highlighted lines need to be added or edited.
@@ -365,7 +365,7 @@
.. literalinclude:: src/authorization/tutorial/templates/view.pt
   :linenos:
   :emphasize-lines: 37-39
   :emphasize-lines: 36-38
   :language: html
Only the highlighted lines need to be added or edited.
docs/tutorials/wiki/src/authorization/.gitignore
New file
@@ -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
docs/tutorials/wiki/src/authorization/README.txt
@@ -14,7 +14,7 @@
- Upgrade packaging tools.
    env/bin/pip install --upgrade pip setuptools wheel
    env/bin/pip install --upgrade pip setuptools
- Install the project in editable mode with its testing requirements.
docs/tutorials/wiki/src/authorization/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/authorization/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/authorization/setup.py
@@ -25,7 +25,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki/src/authorization/tutorial/pshell.py
New file
@@ -0,0 +1,11 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['models'] = models
docs/tutorials/wiki/src/authorization/tutorial/templates/edit.pt
@@ -23,7 +23,6 @@
      <script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js" integrity="sha384-ZoaMbDF+4LeFxg6WdScQ9nnR1QC2MIRxA1O9KWEXQwns1G8UNyIEZIQidzb0T1fo" crossorigin="anonymous"></script>
    <![endif]-->
  </head>
  <body>
    <div class="starter-template">
docs/tutorials/wiki/src/authorization/tutorial/templates/view.pt
@@ -23,7 +23,6 @@
      <script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js" integrity="sha384-ZoaMbDF+4LeFxg6WdScQ9nnR1QC2MIRxA1O9KWEXQwns1G8UNyIEZIQidzb0T1fo" crossorigin="anonymous"></script>
    <![endif]-->
  </head>
  <body>
    <div class="starter-template">
docs/tutorials/wiki/src/basiclayout/.gitignore
New file
@@ -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
docs/tutorials/wiki/src/basiclayout/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/basiclayout/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/basiclayout/setup.py
@@ -23,7 +23,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki/src/basiclayout/tutorial/pshell.py
New file
@@ -0,0 +1,11 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['models'] = models
docs/tutorials/wiki/src/installation/.gitignore
New file
@@ -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
docs/tutorials/wiki/src/installation/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/installation/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/installation/setup.py
@@ -23,7 +23,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki/src/installation/tutorial/pshell.py
New file
@@ -0,0 +1,11 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['models'] = models
docs/tutorials/wiki/src/models/.gitignore
New file
@@ -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
docs/tutorials/wiki/src/models/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/models/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/models/setup.py
@@ -23,7 +23,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki/src/models/tutorial/pshell.py
New file
@@ -0,0 +1,11 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['models'] = models
docs/tutorials/wiki/src/tests/.gitignore
New file
@@ -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
docs/tutorials/wiki/src/tests/README.txt
@@ -14,7 +14,7 @@
- Upgrade packaging tools.
    env/bin/pip install --upgrade pip setuptools wheel
    env/bin/pip install --upgrade pip setuptools
- Install the project in editable mode with its testing requirements.
docs/tutorials/wiki/src/tests/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/tests/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/tests/setup.py
@@ -25,7 +25,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki/src/tests/tutorial/pshell.py
New file
@@ -0,0 +1,11 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['models'] = models
docs/tutorials/wiki/src/tests/tutorial/templates/edit.pt
@@ -23,7 +23,6 @@
      <script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js" integrity="sha384-ZoaMbDF+4LeFxg6WdScQ9nnR1QC2MIRxA1O9KWEXQwns1G8UNyIEZIQidzb0T1fo" crossorigin="anonymous"></script>
    <![endif]-->
  </head>
  <body>
    <div class="starter-template">
docs/tutorials/wiki/src/tests/tutorial/templates/mytemplate.pt
File was deleted
docs/tutorials/wiki/src/tests/tutorial/templates/view.pt
@@ -23,7 +23,6 @@
      <script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js" integrity="sha384-ZoaMbDF+4LeFxg6WdScQ9nnR1QC2MIRxA1O9KWEXQwns1G8UNyIEZIQidzb0T1fo" crossorigin="anonymous"></script>
    <![endif]-->
  </head>
  <body>
    <div class="starter-template">
docs/tutorials/wiki/src/views/.gitignore
New file
@@ -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
docs/tutorials/wiki/src/views/README.txt
@@ -14,7 +14,7 @@
- Upgrade packaging tools.
    env/bin/pip install --upgrade pip setuptools wheel
    env/bin/pip install --upgrade pip setuptools
- Install the project in editable mode with its testing requirements.
docs/tutorials/wiki/src/views/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/views/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki/src/views/setup.py
@@ -24,7 +24,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki/src/views/tutorial/pshell.py
New file
@@ -0,0 +1,11 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['models'] = models
docs/tutorials/wiki2/basiclayout.rst
@@ -44,7 +44,7 @@
above is executed.  It accepts some settings and returns a :term:`WSGI`
application.  (See :ref:`startup_chapter` for more about ``pserve``.)
Next in ``main``, construct a :term:`Configurator` object:
Next in ``main``, construct a :term:`Configurator` object using a context manager:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
    :lines: 7
docs/tutorials/wiki2/src/authentication/development.ini
@@ -24,6 +24,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
@@ -62,7 +65,7 @@
qualname = tutorial
[logger_sqlalchemy]
level = INFO
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
docs/tutorials/wiki2/src/authentication/production.ini
@@ -18,6 +18,9 @@
auth.secret = real-seekrit
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki2/src/authentication/setup.py
@@ -26,7 +26,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki2/src/authentication/tutorial/__init__.py
@@ -4,10 +4,10 @@
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.include('.security')
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.models')
        config.include('.routes')
        config.include('.security')
        config.scan()
    return config.make_wsgi_app()
docs/tutorials/wiki2/src/authentication/tutorial/pshell.py
New file
@@ -0,0 +1,12 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['dbsession'] = request.dbsession
    env['models'] = models
docs/tutorials/wiki2/src/authentication/tutorial/scripts/initialize_db.py
@@ -1,4 +1,4 @@
import os
import argparse
import sys
from pyramid.paster import bootstrap, setup_logging
@@ -24,19 +24,19 @@
    dbsession.add(page)
def usage(argv):
    cmd = os.path.basename(argv[0])
    print('usage: %s <config_uri>\n'
          '(example: "%s development.ini")' % (cmd, cmd))
    sys.exit(1)
def parse_args(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'config_uri',
        help='Configuration file, e.g., development.ini',
    )
    return parser.parse_args(argv[1:])
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap(config_uri)
    args = parse_args(argv)
    setup_logging(args.config_uri)
    env = bootstrap(args.config_uri)
    try:
        with env['request'].tm:
docs/tutorials/wiki2/src/authorization/development.ini
@@ -24,6 +24,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
@@ -62,7 +65,7 @@
qualname = tutorial
[logger_sqlalchemy]
level = INFO
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
docs/tutorials/wiki2/src/authorization/production.ini
@@ -18,6 +18,9 @@
auth.secret = real-seekrit
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki2/src/authorization/setup.py
@@ -26,7 +26,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki2/src/authorization/tutorial/__init__.py
@@ -4,10 +4,10 @@
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.include('.security')
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.models')
        config.include('.routes')
        config.include('.security')
        config.scan()
    return config.make_wsgi_app()
docs/tutorials/wiki2/src/authorization/tutorial/pshell.py
New file
@@ -0,0 +1,12 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['dbsession'] = request.dbsession
    env['models'] = models
docs/tutorials/wiki2/src/authorization/tutorial/scripts/initialize_db.py
@@ -1,4 +1,4 @@
import os
import argparse
import sys
from pyramid.paster import bootstrap, setup_logging
@@ -24,19 +24,19 @@
    dbsession.add(page)
def usage(argv):
    cmd = os.path.basename(argv[0])
    print('usage: %s <config_uri>\n'
          '(example: "%s development.ini")' % (cmd, cmd))
    sys.exit(1)
def parse_args(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'config_uri',
        help='Configuration file, e.g., development.ini',
    )
    return parser.parse_args(argv[1:])
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap(config_uri)
    args = parse_args(argv)
    setup_logging(args.config_uri)
    env = bootstrap(args.config_uri)
    try:
        with env['request'].tm:
docs/tutorials/wiki2/src/basiclayout/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
@@ -60,7 +63,7 @@
qualname = tutorial
[logger_sqlalchemy]
level = INFO
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
docs/tutorials/wiki2/src/basiclayout/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki2/src/basiclayout/setup.py
@@ -24,7 +24,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py
@@ -4,9 +4,9 @@
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.models')
        config.include('.routes')
        config.scan()
    return config.make_wsgi_app()
docs/tutorials/wiki2/src/basiclayout/tutorial/pshell.py
New file
@@ -0,0 +1,12 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['dbsession'] = request.dbsession
    env['models'] = models
docs/tutorials/wiki2/src/basiclayout/tutorial/scripts/initialize_db.py
@@ -1,4 +1,4 @@
import os
import argparse
import sys
from pyramid.paster import bootstrap, setup_logging
@@ -8,23 +8,27 @@
def setup_models(dbsession):
    """
    Add or update models / fixtures in the database.
    """
    model = models.mymodel.MyModel(name='one', value=1)
    dbsession.add(model)
def usage(argv):
    cmd = os.path.basename(argv[0])
    print('usage: %s <config_uri>\n'
          '(example: "%s development.ini")' % (cmd, cmd))
    sys.exit(1)
def parse_args(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'config_uri',
        help='Configuration file, e.g., development.ini',
    )
    return parser.parse_args(argv[1:])
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap(config_uri)
    args = parse_args(argv)
    setup_logging(args.config_uri)
    env = bootstrap(args.config_uri)
    try:
        with env['request'].tm:
docs/tutorials/wiki2/src/installation/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
@@ -60,7 +63,7 @@
qualname = tutorial
[logger_sqlalchemy]
level = INFO
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
docs/tutorials/wiki2/src/installation/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki2/src/installation/setup.py
@@ -24,7 +24,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki2/src/installation/tutorial/__init__.py
@@ -4,9 +4,9 @@
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.models')
        config.include('.routes')
        config.scan()
    return config.make_wsgi_app()
docs/tutorials/wiki2/src/installation/tutorial/pshell.py
New file
@@ -0,0 +1,12 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['dbsession'] = request.dbsession
    env['models'] = models
docs/tutorials/wiki2/src/installation/tutorial/scripts/initialize_db.py
@@ -1,4 +1,4 @@
import os
import argparse
import sys
from pyramid.paster import bootstrap, setup_logging
@@ -8,23 +8,27 @@
def setup_models(dbsession):
    """
    Add or update models / fixtures in the database.
    """
    model = models.mymodel.MyModel(name='one', value=1)
    dbsession.add(model)
def usage(argv):
    cmd = os.path.basename(argv[0])
    print('usage: %s <config_uri>\n'
          '(example: "%s development.ini")' % (cmd, cmd))
    sys.exit(1)
def parse_args(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'config_uri',
        help='Configuration file, e.g., development.ini',
    )
    return parser.parse_args(argv[1:])
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap(config_uri)
    args = parse_args(argv)
    setup_logging(args.config_uri)
    env = bootstrap(args.config_uri)
    try:
        with env['request'].tm:
docs/tutorials/wiki2/src/models/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
@@ -60,7 +63,7 @@
qualname = tutorial
[logger_sqlalchemy]
level = INFO
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
docs/tutorials/wiki2/src/models/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki2/src/models/setup.py
@@ -25,7 +25,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki2/src/models/tutorial/__init__.py
@@ -4,9 +4,9 @@
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.models')
        config.include('.routes')
        config.scan()
    return config.make_wsgi_app()
docs/tutorials/wiki2/src/models/tutorial/pshell.py
New file
@@ -0,0 +1,12 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['dbsession'] = request.dbsession
    env['models'] = models
docs/tutorials/wiki2/src/models/tutorial/scripts/initialize_db.py
@@ -1,4 +1,4 @@
import os
import argparse
import sys
from pyramid.paster import bootstrap, setup_logging
@@ -24,19 +24,19 @@
    dbsession.add(page)
def usage(argv):
    cmd = os.path.basename(argv[0])
    print('usage: %s <config_uri>\n'
          '(example: "%s development.ini")' % (cmd, cmd))
    sys.exit(1)
def parse_args(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'config_uri',
        help='Configuration file, e.g., development.ini',
    )
    return parser.parse_args(argv[1:])
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap(config_uri)
    args = parse_args(argv)
    setup_logging(args.config_uri)
    env = bootstrap(args.config_uri)
    try:
        with env['request'].tm:
docs/tutorials/wiki2/src/tests/development.ini
@@ -24,6 +24,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
@@ -62,7 +65,7 @@
qualname = tutorial
[logger_sqlalchemy]
level = INFO
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
docs/tutorials/wiki2/src/tests/production.ini
@@ -18,6 +18,9 @@
auth.secret = real-seekrit
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki2/src/tests/setup.py
@@ -26,7 +26,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki2/src/tests/tutorial/__init__.py
@@ -4,10 +4,10 @@
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.include('.security')
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.models')
        config.include('.routes')
        config.include('.security')
        config.scan()
    return config.make_wsgi_app()
docs/tutorials/wiki2/src/tests/tutorial/pshell.py
New file
@@ -0,0 +1,12 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['dbsession'] = request.dbsession
    env['models'] = models
docs/tutorials/wiki2/src/tests/tutorial/scripts/initialize_db.py
@@ -1,4 +1,4 @@
import os
import argparse
import sys
from pyramid.paster import bootstrap, setup_logging
@@ -24,19 +24,19 @@
    dbsession.add(page)
def usage(argv):
    cmd = os.path.basename(argv[0])
    print('usage: %s <config_uri>\n'
          '(example: "%s development.ini")' % (cmd, cmd))
    sys.exit(1)
def parse_args(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'config_uri',
        help='Configuration file, e.g., development.ini',
    )
    return parser.parse_args(argv[1:])
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap(config_uri)
    args = parse_args(argv)
    setup_logging(args.config_uri)
    env = bootstrap(args.config_uri)
    try:
        with env['request'].tm:
docs/tutorials/wiki2/src/views/development.ini
@@ -22,6 +22,9 @@
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
@@ -60,7 +63,7 @@
qualname = tutorial
[logger_sqlalchemy]
level = INFO
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
docs/tutorials/wiki2/src/views/production.ini
@@ -16,6 +16,9 @@
retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup
###
# wsgi server configuration
###
docs/tutorials/wiki2/src/views/setup.py
@@ -26,7 +26,7 @@
tests_require = [
    'WebTest >= 1.3.1',  # py3 compat
    'pytest',
    'pytest>=3.7.4',
    'pytest-cov',
]
docs/tutorials/wiki2/src/views/tutorial/__init__.py
@@ -4,9 +4,9 @@
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_jinja2')
    config.include('.models')
    config.include('.routes')
    config.scan()
    with Configurator(settings=settings) as config:
        config.include('pyramid_jinja2')
        config.include('.models')
        config.include('.routes')
        config.scan()
    return config.make_wsgi_app()
docs/tutorials/wiki2/src/views/tutorial/pshell.py
New file
@@ -0,0 +1,12 @@
from . import models
def setup(env):
    request = env['request']
    # start a transaction
    request.tm.begin()
    # inject some vars into the shell builtins
    env['tm'] = request.tm
    env['dbsession'] = request.dbsession
    env['models'] = models
docs/tutorials/wiki2/src/views/tutorial/scripts/initialize_db.py
@@ -1,4 +1,4 @@
import os
import argparse
import sys
from pyramid.paster import bootstrap, setup_logging
@@ -24,19 +24,19 @@
    dbsession.add(page)
def usage(argv):
    cmd = os.path.basename(argv[0])
    print('usage: %s <config_uri>\n'
          '(example: "%s development.ini")' % (cmd, cmd))
    sys.exit(1)
def parse_args(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'config_uri',
        help='Configuration file, e.g., development.ini',
    )
    return parser.parse_args(argv[1:])
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    env = bootstrap(config_uri)
    args = parse_args(argv)
    setup_logging(args.config_uri)
    env = bootstrap(args.config_uri)
    try:
        with env['request'].tm: