Pylons/pyramid — pull request #404 by dnouri (2012-01-17 17:28:41+00:00)
Title: Fix bug with registration of identical views with same 'accept'.

In Kotti I register two views for HTTPForbidden:

config.add_view(
forbidden_redirect,
context=HTTPForbidden,
accept='text/html',
)

config.add_view(
forbidden_view,
context=HTTPForbidden,
)

With this configuration, and due to this bug, it is no longer possible to override the first registration. This call will work (given `autocommit=True` or similar) but will fail to override the existing view such that they both views are registered in the `MultiView` but the first is _sometimes_ preferred:

config.add_view(
another_forbidden_view,
context=HTTPForbidden,
accept='text/html',
)

Note: the fix looks very similar to the overwriting a couple lines above. However, I've added the check for `order == s`, since tests (`TestMultiView.test_add`) expect views with same 'accept' but different 'order' to live alongside each other.

if phash == h and order == s:
subset[i] = (order, view, phash)
return