Chris McDonough
2012-08-26 245f361f4c71dfe1479c40398cc3126f917ab767
- When registering multiple views with an ``accept`` predicate in a Pyramid
application runing under Python 3, you might have received a ``TypeError:
unorderable types: function() < function()`` exception.
3 files modified
31 ■■■■ changed files
CHANGES.txt 4 ●●●● patch | view | raw | blame | history
pyramid/config/views.py 2 ●●● patch | view | raw | blame | history
pyramid/tests/test_config/test_views.py 25 ●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -15,6 +15,10 @@
  asset specs.
  https://github.com/Pylons/pyramid/issues/662
- When registering multiple views with an ``accept`` predicate in a Pyramid
  application runing under Python 3, you might have received a ``TypeError:
  unorderable types: function() < function()`` exception.
1.3.3 (2012-08-10)
==================
pyramid/config/views.py
@@ -564,7 +564,7 @@
                    return
            else:
                subset.append((order, view, phash))
                subset.sort()
                subset.sort(key=operator.itemgetter(0))
            accepts = set(self.accepts)
            accepts.add(accept)
            self.accepts = list(accepts) # dedupe
pyramid/tests/test_config/test_views.py
@@ -2045,11 +2045,28 @@
    def test_add_with_phash_override_accept(self):
        mv = self._makeOne()
        mv.add('view2', 100, accept='text/html', phash='abc')
        mv.add('view3', 100, accept='text/html', phash='abc')
        mv.add('view4', 99, accept='text/html', phash='def')
        def view1(): pass
        def view2(): pass
        def view3(): pass
        mv.add(view1, 100, accept='text/html', phash='abc')
        mv.add(view2, 100, accept='text/html', phash='abc')
        mv.add(view3, 99, accept='text/html', phash='def')
        self.assertEqual(mv.media_views['text/html'],
                         [(99, 'view4', 'def'), (100, 'view3', 'abc')])
                         [(99, view3, 'def'), (100, view2, 'abc')])
    def test_add_with_phash_override_accept2(self):
        mv = self._makeOne()
        def view1(): pass
        def view2(): pass
        def view3(): pass
        mv.add(view1, 100, accept='text/html', phash='abc')
        mv.add(view2, 100, accept='text/html', phash='def')
        mv.add(view3, 99, accept='text/html', phash='ghi')
        self.assertEqual(mv.media_views['text/html'],
                         [(99, view3, 'ghi'),
                          (100, view1, 'abc'),
                          (100, view2, 'def')]
                         )
    def test_multiple_with_functions_as_views(self):
        # this failed on py3 at one point, because functions aren't orderable