{"html_url": "https://github.com/simonw/datasette/issues/1026#issuecomment-719959754", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1026", "id": 719959754, "node_id": "MDEyOklzc3VlQ29tbWVudDcxOTk1OTc1NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-31T16:56:35Z", "updated_at": "2020-10-31T16:56:35Z", "author_association": "OWNER", "body": "#1041 can also benefit from the string subclass that shows that `base_url` has been added.", "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} {"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-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-709636372", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1026", "id": 709636372, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTYzNjM3Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T23:09:34Z", "updated_at": "2020-10-15T23:09:34Z", "author_association": "OWNER", "body": "I'm inclined to say that internal requests should ignore `base_url` - since that seems like the right thing for plugins that need to access default Datasette APIs.\r\n\r\nThe one catch here is plugins that might want to proxy the current incoming URL for some reason - where that incoming `request.path` could include the `base_url`.\r\n\r\nActually those should be fine - because it will have been stripped off earlier:\r\n\r\nhttps://github.com/simonw/datasette/blob/4f7c0ebd85ccd8c1853d7aa0147628f7c1b749cc/datasette/app.py#L963-L968", "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}