summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-07-12 19:21:11 -0400
committerChris McDonough <chrism@plope.com>2011-07-12 19:21:11 -0400
commit94ab244f121fa1bf8df57f75fad9da5f5f39c594 (patch)
tree5f1acdbbdb2de3a500a87d14951542bae1f2408e
parenta7ad42ee5d6ba2304423efaf5fd0c207268144f0 (diff)
downloadpyramid-94ab244f121fa1bf8df57f75fad9da5f5f39c594.tar.gz
pyramid-94ab244f121fa1bf8df57f75fad9da5f5f39c594.tar.bz2
pyramid-94ab244f121fa1bf8df57f75fad9da5f5f39c594.zip
- The ``Configurator.add_route`` method allowed two routes with the same
route to be added without an intermediate ``config.commit()``. If you now receive a ``ConfigurationError`` at startup time that appears to be ``add_route`` related, you'll need to either a) ensure that all of your route names are unique or b) call ``config.commit()`` before adding a second route with the name of a previously added name or c) use a Configurator that works in ``autocommit`` mode.
-rw-r--r--CHANGES.txt11
-rw-r--r--TODO.txt2
-rw-r--r--docs/whatsnew-1.1.rst9
-rw-r--r--pyramid/config.py6
-rw-r--r--pyramid/tests/test_config.py7
5 files changed, 28 insertions, 7 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index b9e645a38..403969fc0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -19,6 +19,17 @@ Behavior Changes
event object) ensure no value already exists in the renderer globals
dictionary before setting an overriding value.
+Bug Fixes
+---------
+
+- The ``Configurator.add_route`` method allowed two routes with the same
+ route to be added without an intermediate ``config.commit()``. If you now
+ receive a ``ConfigurationError`` at startup time that appears to be
+ ``add_route`` related, you'll need to either a) ensure that all of your
+ route names are unique or b) call ``config.commit()`` before adding a
+ second route with the name of a previously added name or c) use a
+ Configurator that works in ``autocommit`` mode.
+
1.1b1 (2011-07-10)
==================
diff --git a/TODO.txt b/TODO.txt
index 637f7e49b..4ff8689ce 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -4,8 +4,6 @@ Pyramid TODOs
Must-Have
---------
-- add_route discriminator wrong
-
- tutorial models.initialize_sql doesn't match scaffold
(DBSession.rollback()/transaction.abort() in scaffold vs. "pass" in
tutorial)
diff --git a/docs/whatsnew-1.1.rst b/docs/whatsnew-1.1.rst
index 345cbfa30..b55b30238 100644
--- a/docs/whatsnew-1.1.rst
+++ b/docs/whatsnew-1.1.rst
@@ -497,6 +497,15 @@ Deprecations and Behavior Differences
exists in the renderer globals dictionary before setting an overriding
value.
+- The :meth:`pyramid.config.Configurator.add_route` method allowed two routes
+ with the same route to be added without an intermediate call to
+ :meth:`pyramid.config.Configurator.commit``. If you now receive a
+ ``ConfigurationError`` at startup time that appears to be ``add_route``
+ related, you'll need to either a) ensure that all of your route names are
+ unique or b) call ``config.commit()`` before adding a second route with the
+ name of a previously added name or c) use a Configurator that works in
+ ``autocommit`` mode.
+
Dependency Changes
------------------
diff --git a/pyramid/config.py b/pyramid/config.py
index 8740d8448..6efb6c00e 100644
--- a/pyramid/config.py
+++ b/pyramid/config.py
@@ -1931,11 +1931,7 @@ class Configurator(object):
if pattern is None:
raise ConfigurationError('"pattern" argument may not be None')
- discriminator = ['route', name, xhr, request_method, path_info,
- request_param, header, accept]
- discriminator.extend(sorted(custom_predicates))
- discriminator = tuple(discriminator)
-
+ discriminator = ('route', name)
self.action(discriminator, None)
return mapper.connect(name, pattern, factory, predicates=predicates,
diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py
index d7e62da0a..84848c2ad 100644
--- a/pyramid/tests/test_config.py
+++ b/pyramid/tests/test_config.py
@@ -1998,6 +1998,13 @@ class ConfiguratorTests(unittest.TestCase):
self._assertRoute(config, 'name', 'path')
self.assertEqual(route.name, 'name')
+ def test_add_route_discriminator(self):
+ config = self._makeOne()
+ route = config.add_route('name', 'path')
+ self._assertRoute(config, 'name', 'path')
+ self.assertEqual(route.name, 'name')
+ self.assertEqual(config._ctx.actions[-1][0], ('route', 'name'))
+
def test_add_route_with_factory(self):
config = self._makeOne(autocommit=True)
factory = object()