summaryrefslogtreecommitdiff
path: root/docs/tutorials/bfgwiki2/basiclayout.rst
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-01-13 15:14:03 +0000
committerChris McDonough <chrism@agendaless.com>2010-01-13 15:14:03 +0000
commit788748e2afedb3d1e180a3033e20ed2d995056a3 (patch)
tree2deb7a16b37ce47341649ad82bdf136a37e751f2 /docs/tutorials/bfgwiki2/basiclayout.rst
parentde449d91fafc0fd4bec6d552dab44845b0948784 (diff)
downloadpyramid-788748e2afedb3d1e180a3033e20ed2d995056a3.tar.gz
pyramid-788748e2afedb3d1e180a3033e20ed2d995056a3.tar.bz2
pyramid-788748e2afedb3d1e180a3033e20ed2d995056a3.zip
- In ``bfg_routesalchemy``, ``bfg_alchemy`` and ``bfgwiki2`` tutorial,
clean up the SQLAlchemy connection by registering a ``repoze.tm.after_end`` callback instead of relying on a ``__del__`` method of a ``Cleanup`` class added to the WSFI environment. The ``__del__`` strategy was fragile and caused problems in the wild. Thanks to Daniel Holth for testing.
Diffstat (limited to 'docs/tutorials/bfgwiki2/basiclayout.rst')
-rw-r--r--docs/tutorials/bfgwiki2/basiclayout.rst23
1 files changed, 9 insertions, 14 deletions
diff --git a/docs/tutorials/bfgwiki2/basiclayout.rst b/docs/tutorials/bfgwiki2/basiclayout.rst
index 5392660da..d30d919c1 100644
--- a/docs/tutorials/bfgwiki2/basiclayout.rst
+++ b/docs/tutorials/bfgwiki2/basiclayout.rst
@@ -119,26 +119,21 @@ function within the file named ``run.py``:
:linenos:
:language: py
-#. *Lines 1-4*. Imports to support later code.
+#. *Lines 1-8*. Imports to support later code.
-#. *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 10-14*. An event :term:`subscriber` which performs cleanup
+ at transaction boundaries. As a result of registering this event
+ subscriber, after the current transaction is committed or aborted,
+ our database connection will be removed.
-#. *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 21-23*. Get the database configuration string from the
+#. *Lines 22-25*. Get the database configuration string from the
``tutorial.ini`` file's ``[app:sql]`` section. This will be a URI
(something like ``sqlite://``).
-#. Line *24*. We initialize our SQL database using SQLAlchemy, passing
+#. Line *26*. We initialize our SQL database using SQLAlchemy, passing
it the db string.
-#. *Line 25*. We construct a :term:`Configurator`. The first
+#. *Line 27*. 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
@@ -146,7 +141,7 @@ function within the file named ``run.py``:
argument. It contains a dictionary of settings parsed by
PasteDeploy.
-#. *Lines 26-29*. We then load a ZCML file to do application
+#. *Lines 28-31*. 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.