summaryrefslogtreecommitdiff
path: root/docs/tutorials/bfgwiki2/basiclayout.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/bfgwiki2/basiclayout.rst')
-rw-r--r--docs/tutorials/bfgwiki2/basiclayout.rst61
1 files changed, 34 insertions, 27 deletions
diff --git a/docs/tutorials/bfgwiki2/basiclayout.rst b/docs/tutorials/bfgwiki2/basiclayout.rst
index b8d0ddcc2..b7c6b795d 100644
--- a/docs/tutorials/bfgwiki2/basiclayout.rst
+++ b/docs/tutorials/bfgwiki2/basiclayout.rst
@@ -25,29 +25,30 @@ following:
:linenos:
:language: xml
-#. *Line 1*. The root ``<configure>`` element, in a ``bfg``
- namespace.
+#. *Line 1*. The root ``<configure>`` element, using the
+ ``http://namespaces.repoze.org/bfg`` namespace.
#. *Line 4*. Boilerplate, the comment explains.
#. *Lines 6-7*. Register a :term:`subscriber` that tears down the
SQLAlchemy connection after a request is finished.
-#. *Lines 9-13*. Register a ``<route>`` that will be used when the
- URL is ``/``. Since this ``<route>`` has an empty ``path``
- attribute, it is the "default" route. The attribute named ``view``
- with the value ``.views.my_view`` is the dotted name to a
- *function* we write (generated by the ``bfg_routesalchemy``
- template) that is given a ``request`` object and which returns a
- response or a dictionary. You will use mostly ``<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 ``.views.my_view`` view returns a dictionary, a
- "renderer" will use this template to create a response.
+#. *Lines 9-13*. Register a ``<route>`` :term:`route configuration`
+ that will be used when the URL is ``/``. Since this ``<route>``
+ has an empty ``path`` attribute, it is the "default" route. The
+ attribute named ``view`` with the value ``.views.my_view`` is the
+ dotted name to a *function* we write (generated by the
+ ``bfg_routesalchemy`` template) that is given a ``request`` object
+ and which returns a response or a dictionary. You will use mostly
+ ``<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
+ ``.views.my_view`` view returns a dictionary, a :term:`renderer`
+ will use this template to create a response.
#. *Lines 15-18*. Register a ``<static>`` directive that will match
- any URL hat starts with ``/static/``. This will serve up static
+ any URL that starts with ``/static/``. This will serve up static
resources for us, in this case, at
``http://localhost:6543/static/`` and below. With this
declaration, we're saying that any URL that starts with ``/static``
@@ -104,40 +105,46 @@ Here is the source for ``models.py``:
App Startup with ``run.py``
---------------------------
-How does a :mod:`repoze.bfg` application start up? When you run under
-``paster`` using the ``tutorial.ini`` generated config file, the
-application area points at an entry point. Our entry point happens to
-be in ``run.py`` and its ``app`` function:
+When you run the application using the ``paster`` command using the
+``tutorial.ini`` generated config file, the application configuration
+points at an Setuptools *entry point* described as
+``egg:tutorial#app``. In our application, because the application's
+``setup.py`` file says so, this entry point happens to be the ``app``
+function within the file named ``run.py``:
.. literalinclude:: src/basiclayout/tutorial/run.py
:linenos:
:language: py
-#. *Lines 1-5*. Imports to support later code.
+#. *Lines 1-4*. Imports to support later code.
-#. *Lines 7-11*. We define a ``Cleanup`` class which has a
+#. *Lines 6-10*. We define a ``Cleanup`` class which has a
``__del__`` method (the method called at Python object
destruction), which calls a function.
-#. *Lines 13-15*. An event :term:`subscriber` which adds a
+#. *Lines 12-14*. An event :term:`subscriber` which adds a
``Cleanup`` instance to the WSGI environment as
``tutorial.sasession``. As a result of registering this event
subscriber, when the WSGI environment is cleaned up, our database
connection will be removed.
-#. *Lines 17-24*. Get the database configuration string from the
+#. *Lines 21-23*. Get the database configuration string from the
``tutorial.ini`` file's ``[app:sql]`` section. This will be a URI
(something like ``sqlite://``).
-#. Line *25*. We initialize our SQL database using SQLAlchemy, passing
+#. Line *24*. We initialize our SQL database using SQLAlchemy, passing
it the db string.
-#. Line *26*. We construct a :term:`Configurator`. The first
+#. *Line 25*. We construct a :term:`Configurator`. The first
argument provided to the configurator is the :term:`root factory`,
which is used by the :mod:`repoze.bfg` :term:`traversal` mechanism.
Since this is a URL dispatch application, the root factory is
``None``. The second argument ``settings`` is passed as a keyword
argument. It contains a dictionary of settings parsed by
- PasteDeploy. We then use the ``make_wsgi_app`` method of the
- :term:`Configurator` to return a :term:`WSGI` application.
+ PasteDeploy.
+
+# *Lines 26-29*. We then load a ZCML file to do application
+ configuration, and use the
+ :meth:`repoze.bfg.configuration.Configurator.make_wsgi_app` method
+ to return a :term:`WSGI` application.