{"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650696054", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650696054, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDY5NjA1NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T04:52:41Z", "updated_at": "2022-03-15T20:07:17Z", "author_association": "OWNER", "body": "This would be a lot easier if I had extracted out the hash logic to a plugin, see:\r\n- #647", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650815278", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650815278, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDgxNTI3OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T20:09:07Z", "updated_at": "2020-06-28T20:11:21Z", "author_association": "OWNER", "body": "There's a lot of complex logic in the `DataView` class, which handles conditionally returning content as `.json` or as HTML or as `.csv`.\r\n\r\nThat view subclasses `AsgiView` which is itself request-aware, so maybe I don't need to reconsider how those classes work - just figure out how to hook them up with `register_routes`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650818086", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650818086, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDgxODA4Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T20:34:33Z", "updated_at": "2020-06-28T20:34:33Z", "author_association": "OWNER", "body": "The key to all of this may be the `DatasetteRouter` class. It deals with `scope` right now but if it internally dealt with `request` that could be enough to fix #864 by adding logic needed by the `.add_message()` mechanism.\r\n\r\nhttps://github.com/simonw/datasette/blob/0991ea75cc7b265389aa8362414a305ba532d31a/datasette/app.py#L904-L938", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650818309", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650818309, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDgxODMwOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T20:36:28Z", "updated_at": "2020-06-28T20:36:52Z", "author_association": "OWNER", "body": "Since `AsgiRouter` is only used as the super-class of the `DatasetteRouter` class maybe I should get rid of `AsgiRouter` entirely - no point in having a Datasette-specific subclass of it if the parent class isn't ever used by anything else.\r\n\r\nI could also rename it to just `Router` which is a nicer name than `DatasetteRouter`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650820068", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650820068, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDgyMDA2OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T20:52:09Z", "updated_at": "2020-06-28T20:53:00Z", "author_association": "OWNER", "body": "Maybe I could add a `as_request_view` method as an alternative to `as_asgi`:\r\n\r\nhttps://github.com/simonw/datasette/blob/a8bcafc1775c8a8655b365ae22a3d64f6361c74a/datasette/utils/asgi.py#L150-L174\r\n\r\nOr I could teach the `Router` to spot the `dispatch_request` method and call it directly.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650834251", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650834251, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDgzNDI1MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T23:03:28Z", "updated_at": "2020-06-28T23:03:28Z", "author_association": "OWNER", "body": "I'm going to ditch that `AsgiView` class too, by combining it into `BaseView`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650834666", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650834666, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDgzNDY2Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T23:07:19Z", "updated_at": "2020-06-28T23:07:19Z", "author_association": "OWNER", "body": "So now the problem is simpler: I need to get `BaseView` to a state where it can accept a shared `request` object and it can be used in conjunction with `register_routes()`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650838691", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650838691, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDgzODY5MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T23:44:12Z", "updated_at": "2020-06-28T23:44:25Z", "author_association": "OWNER", "body": "This code is interesting:\r\n\r\nhttps://github.com/simonw/datasette/blob/3bc2461c77ecba3e1a95301dd440a9bef56b1283/datasette/app.py#L948-L955\r\n\r\nI want to change the signature of that `return await view(new_scope, receive, send)` method to instead take `(request, send)` - so I can have a single shared request object that's created just once per HTTP request.\r\n\r\nThe problem is the scope modification: I have code that modifies the scope, but how should that impact a shared `Request` instance? Should its `.scope` be replaced with alternative scopes as it travels through the codebase?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650838972", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650838972, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDgzODk3Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-28T23:46:40Z", "updated_at": "2020-06-28T23:46:40Z", "author_association": "OWNER", "body": "I'm going to create the single `Request()` instance in the `DatasetteRouter` class - at the beginning of the `route_path` method: https://github.com/simonw/datasette/blob/3bc2461c77ecba3e1a95301dd440a9bef56b1283/datasette/app.py#L905-L925", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/870#issuecomment-650842381", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/870", "id": 650842381, "node_id": "MDEyOklzc3VlQ29tbWVudDY1MDg0MjM4MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-06-29T00:12:07Z", "updated_at": "2020-06-29T00:12:07Z", "author_association": "OWNER", "body": "I've made enough progress on this to be able to solve the messages issue in #864. I may still complete this overall goal (registering internal views with `register_routes()`) as part of Datasette 0.45 but it would be OK if it slipped to a later release.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 646737558, "label": "Refactor default views to use register_routes"}, "performed_via_github_app": null}