{"html_url": "https://github.com/simonw/datasette/issues/1651#issuecomment-1060853226", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1651", "id": 1060853226, "node_id": "IC_kwDOBm6k_c4_O1Xq", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-07T16:04:26Z", "updated_at": "2022-03-07T16:04:26Z", "author_association": "OWNER", "body": "Here's the relevant code:\r\n\r\nhttps://github.com/simonw/datasette/blob/1baa030eca375f839f3471237547ab403523e643/datasette/utils/__init__.py#L753-L772\r\n\r\nhttps://github.com/simonw/datasette/blob/1baa030eca375f839f3471237547ab403523e643/datasette/views/base.py#L451-L479", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1161584460, "label": "Get rid of the no-longer necessary ?_format=json hack for tables called x.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1651#issuecomment-1061053094", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1651", "id": 1061053094, "node_id": "IC_kwDOBm6k_c4_PmKm", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-07T19:29:01Z", "updated_at": "2022-03-07T19:29:01Z", "author_association": "OWNER", "body": "I found an obscure bug in #1650 which I can fix with this too. The following test should pass:\r\n```python\r\n@pytest.mark.parametrize(\r\n \"path,expected\",\r\n (\r\n (\r\n \"/fivethirtyeight/twitter-ratio%2Fsenators\",\r\n \"/fivethirtyeight/twitter-2Dratio-2Fsenators\",\r\n ),\r\n (\r\n \"/fixtures/table%2Fwith%2Fslashes.csv\",\r\n \"/fixtures/table-2Fwith-2Fslashes-2Ecsv\",\r\n ),\r\n # query string should be preserved\r\n (\"/foo/bar%2Fbaz?id=5\", \"/foo/bar-2Fbaz?id=5\"),\r\n ),\r\n)\r\ndef test_redirect_percent_encoding_to_dash_encoding(app_client, path, expected):\r\n response = app_client.get(path)\r\n assert response.status == 302\r\n assert response.headers[\"location\"] == expected\r\n```\r\nIt currently fails like this:\r\n```\r\n> assert response.headers[\"location\"] == expected\r\nE AssertionError: assert '/fixtures/table-2Fwith-2Fslashes.csv?_nofacet=1&_nocount=1' == '/fixtures/table-2Fwith-2Fslashes-2Ecsv'\r\nE - /fixtures/table-2Fwith-2Fslashes-2Ecsv\r\nE + /fixtures/table-2Fwith-2Fslashes.csv?_nofacet=1&_nocount=1\r\n```\r\nBecause the logic in that `get_format()` function notices that the table exists, and then weird things happen here: https://github.com/simonw/datasette/blob/1baa030eca375f839f3471237547ab403523e643/datasette/views/base.py#L288-L303\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1161584460, "label": "Get rid of the no-longer necessary ?_format=json hack for tables called x.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1651#issuecomment-1061169528", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1651", "id": 1061169528, "node_id": "IC_kwDOBm6k_c4_QCl4", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-07T21:47:01Z", "updated_at": "2022-03-07T21:47:01Z", "author_association": "OWNER", "body": "Wow, this code is difficult to follow! Look at this bit inside the `get_format()` method:\r\n\r\nhttps://github.com/simonw/datasette/blob/bb499942c15c4e2cfa4b6afab8f8debe5948c009/datasette/views/base.py#L469-L478\r\n\r\nThat's modifying the arguments that were extracted from the path by the routing regular expressions to have `table` as ` dash-decoded value! So calling `.get_format()` has the side effect of decoding the table names for you. Nasty.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1161584460, "label": "Get rid of the no-longer necessary ?_format=json hack for tables called x.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1651#issuecomment-1061170897", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1651", "id": 1061170897, "node_id": "IC_kwDOBm6k_c4_QC7R", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-07T21:48:35Z", "updated_at": "2022-03-07T21:48:35Z", "author_association": "OWNER", "body": "My attempts to simplify `get_format()` keep resulting in errors like this one:\r\n```\r\n File \"/Users/simon/Dropbox/Development/datasette/datasette/views/base.py\", line 474, in view_get\r\n response_or_template_contexts = await self.data(\r\nTypeError: TableView.data() missing 1 required positional argument: 'table'\r\n```\r\nI really need to clean this up.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1161584460, "label": "Get rid of the no-longer necessary ?_format=json hack for tables called x.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1651#issuecomment-1061223822", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1651", "id": 1061223822, "node_id": "IC_kwDOBm6k_c4_QP2O", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-07T22:54:54Z", "updated_at": "2022-03-07T22:54:54Z", "author_association": "OWNER", "body": "I'm going to do a review of how URL routing works at the moment for the various views.\r\n\r\nI edited down [the full list](https://github.com/simonw/datasette/blob/c5791156d92615f25696ba93dae5bb2dcc192c98/datasette/app.py#L997-L1107) a bit - these are the most relevant:\r\n```python\r\nadd_route(IndexView.as_view(self), r\"/(?P(\\.jsono?)?$)\")\r\nadd_route(\r\n DatabaseView.as_view(self),\r\n r\"/(?P[^/]+?)(?P\"\r\n + renderer_regex\r\n + r\"|.jsono|\\.csv)?$\",\r\n)\r\nadd_route(\r\n TableView.as_view(self),\r\n r\"/(?P[^/]+)/(?P[^/]+?$)\",\r\n)\r\nadd_route(\r\n RowView.as_view(self),\r\n r\"/(?P[^/]+)/(?P[^/]+?)/(?P[^/]+?)(?P\"\r\n + renderer_regex\r\n + r\")?$\",\r\n)\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1161584460, "label": "Get rid of the no-longer necessary ?_format=json hack for tables called x.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1651#issuecomment-1061359915", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1651", "id": 1061359915, "node_id": "IC_kwDOBm6k_c4_QxEr", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-08T03:08:14Z", "updated_at": "2022-03-08T03:09:24Z", "author_association": "OWNER", "body": "A lot of the code complexity here is caused by `DataView` ([here](https://github.com/simonw/datasette/blob/c5791156d92615f25696ba93dae5bb2dcc192c98/datasette/views/base.py#L182-L669)), which has the logic for CSV streaming and plugin formats such that it can be shared between tables and custom queries.\r\n\r\nIt would be good to get rid of that subclassed shared code, figure out how to do it via a utility function instead.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1161584460, "label": "Get rid of the no-longer necessary ?_format=json hack for tables called x.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1651#issuecomment-1067382442", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1651", "id": 1067382442, "node_id": "IC_kwDOBm6k_c4_nvaq", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-14T22:59:10Z", "updated_at": "2022-03-14T22:59:10Z", "author_association": "OWNER", "body": "This work is now blocked on:\r\n- https://github.com/simonw/datasette/issues/1657", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1161584460, "label": "Get rid of the no-longer necessary ?_format=json hack for tables called x.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1651#issuecomment-1068319530", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1651", "id": 1068319530, "node_id": "IC_kwDOBm6k_c4_rUMq", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-15T18:25:42Z", "updated_at": "2022-03-15T18:25:42Z", "author_association": "OWNER", "body": "Done:\r\n\r\n- https://latest.datasette.io/fixtures/table~2Fwith~2Fslashes~2Ecsv\r\n- https://latest.datasette.io/fixtures/table~2Fwith~2Fslashes~2Ecsv.csv\r\n- https://latest.datasette.io/fixtures/table~2Fwith~2Fslashes~2Ecsv.json", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1161584460, "label": "Get rid of the no-longer necessary ?_format=json hack for tables called x.json"}, "performed_via_github_app": null}