From 607d756e962dce912134e075dbcc5f11a91987f0 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 19 Jan 2011 21:34:19 -0500 Subject: - The ``pyramid_zodb``, ``pyramid_routesalchemy`` and ``pyramid_alchemy`` paster templates now use a default "commit veto" hook when configuring the ``repoze.tm2`` transaction manager in ``development.ini``. This prevents a transaction from being committed when the response status code is within the 400 or 500 ranges. See also http://docs.repoze.org/tm2/#using-a-commit-veto. --- CHANGES.txt | 10 ++++++++++ TODO.txt | 3 --- docs/tutorials/wiki/basiclayout.rst | 8 +++++--- pyramid/paster_templates/alchemy/development.ini_tmpl | 6 +++++- pyramid/paster_templates/alchemy/setup.py_tmpl | 2 +- pyramid/paster_templates/routesalchemy/development.ini_tmpl | 8 ++++++-- pyramid/paster_templates/routesalchemy/setup.py_tmpl | 2 +- pyramid/paster_templates/zodb/development.ini_tmpl | 6 +++++- pyramid/paster_templates/zodb/setup.py_tmpl | 2 +- 9 files changed, 34 insertions(+), 13 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 86473b9b3..416de00f9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -35,6 +35,16 @@ Backwards Incompatibilities has been mutated, a cookie will be sent back in the response. Previously its default value was ``False``. +Paster Templates +---------------- + +- The ``pyramid_zodb``, ``pyramid_routesalchemy`` and ``pyramid_alchemy`` + paster templates now use a default "commit veto" hook when configuring the + ``repoze.tm2`` transaction manager in ``development.ini``. This prevents a + transaction from being committed when the response status code is within + the 400 or 500 ranges. See also + http://docs.repoze.org/tm2/#using-a-commit-veto. + 1.0a10 (2011-01-18) =================== diff --git a/TODO.txt b/TODO.txt index 75dc5199f..e34c2fe55 100644 --- a/TODO.txt +++ b/TODO.txt @@ -6,9 +6,6 @@ Must-Have (before 1.0) - Write a "Whats New" (delta from BFG 1.3) -- Use a commit veto when configuring repoze.tm2 in paster templates for - non-1X, 2X, or 3X responses. - - Figure out how to slim the herd of paster templates. Related: https://github.com/Pylons/pyramid/issues#issue/40, https://github.com/Pylons/pyramid/issues#issue/42, diff --git a/docs/tutorials/wiki/basiclayout.rst b/docs/tutorials/wiki/basiclayout.rst index 4017d7af8..884f17840 100644 --- a/docs/tutorials/wiki/basiclayout.rst +++ b/docs/tutorials/wiki/basiclayout.rst @@ -187,9 +187,11 @@ The ``egg:repoze.zodbconn#closer`` middleware is in the middle of the pipeline. This is a piece of middleware which closes the ZODB connection opened by the ``PersistentApplicationFinder`` at the end of the request. -The ``egg:repoze.tm#tm`` middleware is the last piece of middleware in the -pipeline. This commits a transaction near the end of the request unless -there's an exception raised. +The ``tm`` middleware is the last piece of middleware in the pipeline. This +commits a transaction near the end of the request unless there's an exception +raised or the HTTP response code is an error code. The ``tm`` refers to the +``[filter:tm]`` section beneath the pipeline declaration, which configures +the transaction manager. The final line in the ``[pipeline:main]`` section is ``tutorial``, which refers to the ``[app:tutorial]`` section above it. The ``[app:tutorial]`` diff --git a/pyramid/paster_templates/alchemy/development.ini_tmpl b/pyramid/paster_templates/alchemy/development.ini_tmpl index bf672ef1d..619b193dc 100644 --- a/pyramid/paster_templates/alchemy/development.ini_tmpl +++ b/pyramid/paster_templates/alchemy/development.ini_tmpl @@ -11,9 +11,13 @@ sqlalchemy.url = sqlite:///%(here)s/{{project}}.db [pipeline:main] pipeline = egg:WebError#evalerror - egg:repoze.tm2#tm + tm {{package}} +[filter:tm] +use = egg:repoze.tm2#tm +commit_veto = repoze.tm:default_commit_veto + [server:main] use = egg:Paste#http host = 0.0.0.0 diff --git a/pyramid/paster_templates/alchemy/setup.py_tmpl b/pyramid/paster_templates/alchemy/setup.py_tmpl index 591b57d9d..8e9da9755 100644 --- a/pyramid/paster_templates/alchemy/setup.py_tmpl +++ b/pyramid/paster_templates/alchemy/setup.py_tmpl @@ -9,7 +9,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.txt')).read() requires = [ 'pyramid', - 'repoze.tm2', + 'repoze.tm2>=1.0b1', # default_commit_veto 'sqlalchemy', 'zope.sqlalchemy', 'WebError', diff --git a/pyramid/paster_templates/routesalchemy/development.ini_tmpl b/pyramid/paster_templates/routesalchemy/development.ini_tmpl index b79dfccfe..7f1d6af9b 100644 --- a/pyramid/paster_templates/routesalchemy/development.ini_tmpl +++ b/pyramid/paster_templates/routesalchemy/development.ini_tmpl @@ -11,8 +11,12 @@ sqlalchemy.url = sqlite:///%(here)s/{{project}}.db [pipeline:main] pipeline = egg:WebError#evalerror - egg:repoze.tm2#tm - {{project}} + tm + {{package}} + +[filter:tm] +use = egg:repoze.tm2#tm +commit_veto = repoze.tm:default_commit_veto [server:main] use = egg:Paste#http diff --git a/pyramid/paster_templates/routesalchemy/setup.py_tmpl b/pyramid/paster_templates/routesalchemy/setup.py_tmpl index 80b756214..936a5dde0 100644 --- a/pyramid/paster_templates/routesalchemy/setup.py_tmpl +++ b/pyramid/paster_templates/routesalchemy/setup.py_tmpl @@ -11,7 +11,7 @@ requires = [ 'pyramid', 'SQLAlchemy', 'transaction', - 'repoze.tm2', + 'repoze.tm2>=1.0b1', # default_commit_veto 'zope.sqlalchemy', 'WebError', ] diff --git a/pyramid/paster_templates/zodb/development.ini_tmpl b/pyramid/paster_templates/zodb/development.ini_tmpl index 110d514e6..0a88094b3 100644 --- a/pyramid/paster_templates/zodb/development.ini_tmpl +++ b/pyramid/paster_templates/zodb/development.ini_tmpl @@ -12,9 +12,13 @@ zodb_uri = file://%(here)s/Data.fs?connection_cache_size=20000 pipeline = egg:WebError#evalerror egg:repoze.zodbconn#closer - egg:repoze.tm#tm + tm {{project}} +[filter:tm] +use = egg:repoze.tm2#tm +commit_veto = repoze.tm:default_commit_veto + [server:main] use = egg:Paste#http host = 0.0.0.0 diff --git a/pyramid/paster_templates/zodb/setup.py_tmpl b/pyramid/paster_templates/zodb/setup.py_tmpl index cd1de15de..a6ef572ac 100644 --- a/pyramid/paster_templates/zodb/setup.py_tmpl +++ b/pyramid/paster_templates/zodb/setup.py_tmpl @@ -9,7 +9,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.txt')).read() requires = [ 'pyramid', 'repoze.zodbconn', - 'repoze.tm', + 'repoze.tm2>=1.0b1', # default_commit_veto 'ZODB3', 'WebError', ] -- cgit v1.2.3