summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2/basiclayout.rst
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2015-10-21 00:34:10 -0500
committerMichael Merickel <michael@merickel.org>2015-10-21 00:34:10 -0500
commit504027873ab0e1b15601e2d1900ef8a4469f6a43 (patch)
tree06e6cbf634a894dbce232c9dbb06324637a95a86 /docs/tutorials/wiki2/basiclayout.rst
parentbf40a3920278b3e7a01ef5403196b35f45cfcb3c (diff)
parente1ec631ab2d470b1550640d21c28ddd1387f4045 (diff)
downloadpyramid-504027873ab0e1b15601e2d1900ef8a4469f6a43.tar.gz
pyramid-504027873ab0e1b15601e2d1900ef8a4469f6a43.tar.bz2
pyramid-504027873ab0e1b15601e2d1900ef8a4469f6a43.zip
Merge pull request #2020 from bertjwregeer/feature/configurable-view-deriver
Configurable View Deriver moving forward...
Diffstat (limited to 'docs/tutorials/wiki2/basiclayout.rst')
-rw-r--r--docs/tutorials/wiki2/basiclayout.rst22
1 files changed, 13 insertions, 9 deletions
diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst
index 05781c044..80ae4b34e 100644
--- a/docs/tutorials/wiki2/basiclayout.rst
+++ b/docs/tutorials/wiki2/basiclayout.rst
@@ -4,16 +4,17 @@ Basic Layout
The starter files generated by the ``alchemy`` scaffold are very basic, but
they provide a good orientation for the high-level patterns common to most
-:term:`url dispatch` -based :app:`Pyramid` projects.
+:term:`URL dispatch`-based :app:`Pyramid` projects.
-Application Configuration with ``__init__.py``
+Application configuration with ``__init__.py``
----------------------------------------------
A directory on disk can be turned into a Python :term:`package` by containing
an ``__init__.py`` file. Even if empty, this marks a directory as a Python
-package. We use ``__init__.py`` both as a marker indicating the directory
-it's contained within is a package, and to contain configuration code.
+package. We use ``__init__.py`` both as a marker, indicating the directory
+in which it's contained is a package, and to contain application configuration
+code.
Open ``tutorial/tutorial/__init__.py``. It should already contain
the following:
@@ -114,7 +115,7 @@ used when the URL is ``/``:
:lines: 19
:language: py
-Since this route has a ``pattern`` equalling ``/`` it is the route that will
+Since this route has a ``pattern`` equaling ``/`` it is the route that will
be matched when the URL ``/`` is visited, e.g. ``http://localhost:6543/``.
``main`` next calls the ``scan`` method of the configurator
@@ -136,7 +137,7 @@ Finally, ``main`` is finished configuring things, so it uses the
:lines: 21
:language: py
-View Declarations via ``views.py``
+View declarations via ``views.py``
----------------------------------
The main function of a web framework is mapping each URL pattern to code (a
@@ -167,7 +168,7 @@ Note that ``my_view()`` accepts a single argument named ``request``. This is
the standard call signature for a Pyramid :term:`view callable`.
Remember in our ``__init__.py`` when we executed the
-:meth:`pyramid.config.Configurator.scan` method, i.e. ``config.scan()``? The
+:meth:`pyramid.config.Configurator.scan` method ``config.scan()``? The
purpose of calling the scan method was to find and process this
``@view_config`` decorator in order to create a view configuration within our
application. Without being processed by ``scan``, the decorator effectively
@@ -175,7 +176,7 @@ does nothing. ``@view_config`` is inert without being detected via a
:term:`scan`.
The sample ``my_view()`` created by the scaffold uses a ``try:`` and ``except:``
-clause, to detect if there is a problem accessing the project database and
+clause to detect if there is a problem accessing the project 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.
@@ -203,7 +204,7 @@ Let's examine this in detail. First, we need some imports to support later code:
Next we set up a SQLAlchemy ``DBSession`` object:
.. literalinclude:: src/basiclayout/tutorial/models.py
- :lines: 16
+ :lines: 17
:language: py
``scoped_session`` and ``sessionmaker`` are standard SQLAlchemy helpers.
@@ -246,5 +247,8 @@ The ``MyModel`` class has a ``__tablename__`` attribute. This informs
SQLAlchemy which table to use to store the data representing instances of this
class.
+The Index import and the Index object creation is not required for this
+tutorial, and will be removed in the next step.
+
That's about all there is to it regarding models, views, and initialization
code in our stock application.