{"action":"opened","issue":{"url":"https://api.github.com/repos/juju/docs/issues/911","repository_url":"https://api.github.com/repos/juju/docs","labels_url":"https://api.github.com/repos/juju/docs/issues/911/labels{/name}","comments_url":"https://api.github.com/repos/juju/docs/issues/911/comments","events_url":"https://api.github.com/repos/juju/docs/issues/911/events","html_url":"https://github.com/juju/docs/issues/911","id":136022718,"number":911,"title":"http interface layer requires.py flawed","user":{"login":"stub42","id":2928805,"avatar_url":"https://avatars.githubusercontent.com/u/2928805?v=3","gravatar_id":"","url":"https://api.github.com/users/stub42","html_url":"https://github.com/stub42","followers_url":"https://api.github.com/users/stub42/followers","following_url":"https://api.github.com/users/stub42/following{/other_user}","gists_url":"https://api.github.com/users/stub42/gists{/gist_id}","starred_url":"https://api.github.com/users/stub42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stub42/subscriptions","organizations_url":"https://api.github.com/users/stub42/orgs","repos_url":"https://api.github.com/users/stub42/repos","events_url":"https://api.github.com/users/stub42/events{/privacy}","received_events_url":"https://api.github.com/users/stub42/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-24T10:46:17Z","updated_at":"2016-02-24T10:46:17Z","closed_at":null,"body":"The example at https://jujucharms.com/docs/devel/developer-layers-interfaces#writing-the-requires-side is flawed, assuming that the providing service provides a single http relation.\r\n\r\n```python\r\n        services = {}\r\n        for conv in self.conversations():\r\n            service_name = conv.scope.split('/')[0]\r\n            service = services.setdefault(service_name, {\r\n                'service_name': service_name,\r\n                'hosts': [],\r\n            })\r\n```\r\n\r\nIf the provider provides multiple http relations, then the services() method on the requires side will mash them together returning info about a single http relation with arbitrary ports and hostnames."}}