diff options
Diffstat (limited to 'docs/tutorials/wiki2/basiclayout.rst')
| -rw-r--r-- | docs/tutorials/wiki2/basiclayout.rst | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index b3184c4fc..dbd130c36 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -51,21 +51,33 @@ The main function first creates a SQLAlchemy database engine using (something like ``sqlite://``): .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 9 + :lines: 12 :linenos: :language: py -``main`` then initializes our SQL database using SQLAlchemy, passing it the +``main`` then initializes our SQLAlchemy session object, passing it the engine: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 10 + :lines: 13 + :language: py + +``main`` subsequently initializes our SQLAlchemy declarative Base object, +assigning the engine we created to the ``bind`` attribute of it's +``metadata`` object. This allows table definitions done imperatively +(instead of declaratively, via a class statement) to work. We won't use any +such tables in our application, but if you add one later, long after you've +forgotten about this tutorial, you won't be left scratching your head when it +doesn't work. + + .. literalinclude:: src/basiclayout/tutorial/__init__.py + :lines: 14 :language: py The next step of ``main`` is to construct a :term:`Configurator` object: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 11 + :lines: 15 :language: py ``settings`` is passed to the Configurator as a keyword argument with the @@ -78,7 +90,7 @@ deployment-related values such as ``pyramid.reload_templates``, two arguments: ``static`` (the name), and ``static`` (the path): .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 12 + :lines: 16 :language: py This registers a static resource view which will match any URL that starts @@ -96,7 +108,7 @@ via the :meth:`pyramid.config.Configurator.add_route` method that will be used when the URL is ``/``: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 13 + :lines: 17 :language: py Since this route has a ``pattern`` equalling ``/`` it is the route that will @@ -109,7 +121,7 @@ view configuration will be registered, which will allow one of our application URLs to be mapped to some code. .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 14 + :lines: 18 :language: py Finally, ``main`` is finished configuring things, so it uses the @@ -117,7 +129,7 @@ Finally, ``main`` is finished configuring things, so it uses the :term:`WSGI` application: .. literalinclude:: src/basiclayout/tutorial/__init__.py - :lines: 15 + :lines: 19 :language: py View Declarations via ``views.py`` |
