{"action":"created","issue":{"url":"https://api.github.com/repos/Pylons/pyramid/issues/1264","repository_url":"https://api.github.com/repos/Pylons/pyramid","labels_url":"https://api.github.com/repos/Pylons/pyramid/issues/1264/labels{/name}","comments_url":"https://api.github.com/repos/Pylons/pyramid/issues/1264/comments","events_url":"https://api.github.com/repos/Pylons/pyramid/issues/1264/events","html_url":"https://github.com/Pylons/pyramid/issues/1264","id":28990436,"number":1264,"title":"accept handling during view lookup is unpredictable","user":{"login":"mmerickel","id":487237,"avatar_url":"https://avatars.githubusercontent.com/u/487237?v=3","gravatar_id":"","url":"https://api.github.com/users/mmerickel","html_url":"https://github.com/mmerickel","followers_url":"https://api.github.com/users/mmerickel/followers","following_url":"https://api.github.com/users/mmerickel/following{/other_user}","gists_url":"https://api.github.com/users/mmerickel/gists{/gist_id}","starred_url":"https://api.github.com/users/mmerickel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmerickel/subscriptions","organizations_url":"https://api.github.com/users/mmerickel/orgs","repos_url":"https://api.github.com/users/mmerickel/repos","events_url":"https://api.github.com/users/mmerickel/events{/privacy}","received_events_url":"https://api.github.com/users/mmerickel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2014-03-07T19:12:34Z","updated_at":"2016-03-14T21:42:44Z","closed_at":null,"body":"As per the examples in #1259, it should be clear that the accept handling in Pyramid is somewhat unpredictable. It is a smell that the view invoked is somewhat dependent on the ordering of a `set`. When defining some views with accept predicates, a user should be able to have a solid understanding of when each view will be invoked, and possibly be able to influence what happens what a client simply asks for `*/*` or does not include an `Accept` header."},"comment":{"url":"https://api.github.com/repos/Pylons/pyramid/issues/comments/196533738","html_url":"https://github.com/Pylons/pyramid/issues/1264#issuecomment-196533738","issue_url":"https://api.github.com/repos/Pylons/pyramid/issues/1264","id":196533738,"user":{"login":"mmerickel","id":487237,"avatar_url":"https://avatars.githubusercontent.com/u/487237?v=3","gravatar_id":"","url":"https://api.github.com/users/mmerickel","html_url":"https://github.com/mmerickel","followers_url":"https://api.github.com/users/mmerickel/followers","following_url":"https://api.github.com/users/mmerickel/following{/other_user}","gists_url":"https://api.github.com/users/mmerickel/gists{/gist_id}","starred_url":"https://api.github.com/users/mmerickel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmerickel/subscriptions","organizations_url":"https://api.github.com/users/mmerickel/orgs","repos_url":"https://api.github.com/users/mmerickel/repos","events_url":"https://api.github.com/users/mmerickel/events{/privacy}","received_events_url":"https://api.github.com/users/mmerickel/received_events","type":"User","site_admin":false},"created_at":"2016-03-14T21:42:44Z","updated_at":"2016-03-14T21:42:44Z","body":"> All I generally care about is that text/html is selected when the browser hits my Pyramid app, and all other requests are JSON from JavaScript and those all hit application/json.\r\n\r\nSo hypothetically let's use the solution I've described as it's the only one I can find that's actually concretely defined. How does a user get that to work?\r\n\r\n```python\r\nconfig.add_view(..., accept='application/json')\r\nconfig.add_view(..., accept='text/html')\r\nconfig.add_view(..., accept=None)\r\n```\r\n\r\nThis snippet works fine when the client specified different quality for application/json and text/html. How can we change that snippet to work when the client specifies the same quality?\r\n\r\n```\r\nconfig.add_view(..., accept='application/json')\r\nconfig.add_view(..., accept='text/html;q=0.9')\r\n```\r\n\r\nOkay, we now declare that we prefer application/json. Using multiplication we get that application/json;q=1.0*1.0=1.0 and text/html;q=1.0*0.9=0.9 so we will prefer application/json.\r\n\r\nIs this what we want? Now when a client requests text/html they will get back application/json unless they specific give text/html a higher quality. So let's say they do that and specify `text/html,application/json;q=0.8`. Now we have application/json;q=0.8,text/html;q=0.9. So the client will receive html. Note that the selection of 0.8 by the client was dependent on knowing that the server defined q=0.9. If the client said 0.9 we'd still have an issue!\r\n\r\nLong story short, I'm not sure multiplying `client_q * server_q` is the right answer. We may just want to construct a sorted list on the server using the weights as sorting keys."}}