{"html_url": "https://github.com/simonw/datasette/issues/1026#issuecomment-712607227", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1026", "id": 712607227, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjYwNzIyNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-20T05:46:44Z", "updated_at": "2020-10-20T05:46:44Z", "author_association": "OWNER", "body": "We have a solution for this now: `datasette.urls` from #1033 can be used by plugins to assemble the correct URLs to pass to `.get()` and friends.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 722738988, "label": "How should datasette.client interact with base_url"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1026#issuecomment-712959034", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1026", "id": 712959034, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjk1OTAzNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-20T16:03:33Z", "updated_at": "2020-10-20T16:03:55Z", "author_association": "OWNER", "body": "Reconsidering this: I think the `.get()` etc methods should automatically add the `base_url` prefix for you, since these APIs are only intended to make internal calls.\r\n\r\nThe clincher on this is when I went to add a section to the `datasette.client` documentation recommending you use `datasette.urls.path()` for every call to them that you make.\r\n\r\nBut there's a problem: to handle table name escaping users are likely to want to use `datasette.urls.table()` anyway, like this:\r\n\r\n response = await datasette.client.get(datasette.urls.table(\"db\", \"table\") + \".json\")\r\n\r\nThis risks adding the `base_url` prefix twice. Maybe the `.table()` method could return a string-like object that is marked as already having the `base_url` prefix added, so the `client.get()` method knows not to add it again.\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 722738988, "label": "How should datasette.client interact with base_url"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1026#issuecomment-712962517", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1026", "id": 712962517, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjk2MjUxNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-20T16:09:12Z", "updated_at": "2020-10-20T16:09:12Z", "author_association": "OWNER", "body": "That `datasette.urls.table(\"db\", \"table\") + \".json\"` example is bad because if the table name contains a `.` it should be `?_format=json` instead.\r\n\r\nMaybe `.table()` should have a `format=\"json\"` option that knows how to do this.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 722738988, "label": "How should datasette.client interact with base_url"}, "performed_via_github_app": null}