summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2/basiclayout.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/wiki2/basiclayout.rst')
-rw-r--r--docs/tutorials/wiki2/basiclayout.rst57
1 files changed, 28 insertions, 29 deletions
diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst
index c73009eb0..4d3496788 100644
--- a/docs/tutorials/wiki2/basiclayout.rst
+++ b/docs/tutorials/wiki2/basiclayout.rst
@@ -2,10 +2,9 @@
Basic Layout
============
-The starter files generated by the ``pyramid_routesalchemy`` template
-are basic, but they provide a good orientation for the high-level
-patterns common to most :term:`url dispatch` -based :app:`Pyramid`
-projects.
+The starter files generated by the ``pyramid_routesalchemy`` template are
+basic, but they provide a good orientation for the high-level patterns common
+to most :term:`url dispatch` -based :app:`Pyramid` projects.
The source code for this tutorial stage can be browsed at
`http://github.com/Pylons/pyramid/tree/master/docs/tutorials/wiki2/src/basiclayout/
@@ -32,9 +31,9 @@ First we need some imports to support later code:
:linenos:
:language: py
-Next we define the main function and create a SQLAlchemy database
-engine from the ``sqlalchemy.`` prefixed settings in the ``development.ini`
-`file's ``[app:tutorial]`` section. This will be a URI (something like
+Next we define the main function and create a SQLAlchemy database engine from
+the ``sqlalchemy.`` prefixed settings in the ``development.ini`` file's
+``[app:tutorial]`` section. This will be a URI (something like
``sqlite://``):
.. literalinclude:: src/basiclayout/tutorial/__init__.py
@@ -55,10 +54,10 @@ The next step is to construct a :term:`Configurator`:
:lines: 11
:language: py
-``settings`` is passed as a keyword argument with the dictionary values
-passed by PasteDeploy as the ``settings`` argument. This will be a
-dictionary of settings parsed by PasteDeploy, which contains
-deployment-related values such as ``reload_templates``,
+``settings`` is passed to the Configurator as a keyword argument with the
+dictionary values passed by PasteDeploy as the ``**settings`` argument. This
+will be a dictionary of settings parsed from the ``.ini`` file, which
+contains deployment-related values such as ``reload_templates``,
``db_string``, etc.
We now can call :meth:`pyramid.config.Configurator.add_static_view` with the
@@ -85,18 +84,19 @@ used when the URL is ``/``:
:lines: 13-14
:language: py
-Since this route has a ``pattern`` equalling
-``/`` it is the "default" route. The argument named ``view`` with the
-value ``tutorial.views.my_view`` is the dotted name to a *function* we
-write (generated by the ``pyramid_routesalchemy`` template) that is given
-a ``request`` object and which returns a response or a dictionary.
+Since this route has a ``pattern`` equalling ``/`` it is the route that will
+be called when the URL ``/`` is visted, e.g. ``http://localhost:6543/``. The
+argument named ``view`` with the value ``tutorial.views.my_view`` is the
+dotted name to a *function* we write (generated by the
+``pyramid_routesalchemy`` template) that is given a ``request`` object and
+which returns a response or a dictionary.
-You will use :meth:`pyramid.config.Configurator.add_route` statements
-in a :term:`URL dispatch` based application to map URLs to code. This
-route also names a ``view_renderer``, which is a template which lives in
-the ``templates`` subdirectory of the package. When the
-``tutorial.views.my_view`` view returns a dictionary, a :term:`renderer`
-will use this template to create a response.
+You will use :meth:`pyramid.config.Configurator.add_route` statements in a
+:term:`URL dispatch` based application to map URLs to code. This route also
+names a ``view_renderer``, which is a template which lives in the
+``templates`` subdirectory of the package. When the
+``tutorial.views.my_view`` view returns a dictionary, a :term:`renderer` will
+use this template to create a response.
Fimnally, we use the :meth:`pyramid.config.Configurator.make_wsgi_app`
method to return a :term:`WSGI` application:
@@ -105,7 +105,7 @@ method to return a :term:`WSGI` application:
:lines: 15
:language: py
-Our final __init__.py file will look like this:
+Our final ``__init__.py`` file will look like this:
.. literalinclude:: src/basiclayout/tutorial/__init__.py
:linenos:
@@ -148,12 +148,11 @@ To give a simple example of a model class, we define one named ``MyModel``:
:linenos:
:language: py
-Our sample model has an ``__init__`` that takes a two arguments
-(``name``, and ``value``).
-It stores these values as ``self.name`` and ``self.value`` within
-the ``__init__`` function itself. The ``MyModel`` class also has a
-``__tablename__`` attribute. This informs SQLAlchemy which table
-to use to store the data representing instances of this class.
+Our sample model has an ``__init__`` that takes a two arguments (``name``,
+and ``value``). It stores these values as ``self.name`` and ``self.value``
+within the ``__init__`` function itself. The ``MyModel`` class also has a
+``__tablename__`` attribute. This informs SQLAlchemy which table to use to
+store the data representing instances of this class.
Next we define a function named ``populate`` which adds a single
model instance into our SQL storage and commits a transaction: