{"html_url": "https://github.com/simonw/datasette/issues/187#issuecomment-502401636", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/187", "id": 502401636, "node_id": "MDEyOklzc3VlQ29tbWVudDUwMjQwMTYzNg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-15T21:44:23Z", "updated_at": "2019-06-15T21:44:23Z", "author_association": "OWNER", "body": "I'm closing his as a duplicate of the new #511 - I hope to have his working very shortly as a result of #272 ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 309033998, "label": "Windows installation error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/272#issuecomment-502393107", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/272", "id": 502393107, "node_id": "MDEyOklzc3VlQ29tbWVudDUwMjM5MzEwNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-15T19:25:54Z", "updated_at": "2019-06-19T01:20:14Z", "author_association": "OWNER", "body": "OK, time for a solid implementation plan.\r\n\r\nAs soon as https://github.com/django/asgiref/pull/92 is merged (hopefully very soon) the ASGI spec will have support for an optional `raw_path` - which means we can continue to use `table%2Fnames` with embedded `/` without being unable to tell if a path has been decoded or not.\r\n\r\nSteps to implement:\r\n\r\n## Refactor classes, then add .asgi() method to BaseView\r\n\r\nAdd a `.asgi(self, scope, receive, send)` method to my base view class. This will expose an ASGI interface to the outside world: the method itself will construct a request object and call the existing `.get()` method.\r\n\r\nMy only true shared base class is actually `RenderMixin` because the `IndexView` doesn't extend `BaseView`. I'm going to refactor the class hierarchy a bit here - `AsgiView` will be my top level class with the `.asgi()` method on it. `RenderMixin` will be renamed `BaseView(AsgiView)`, while existing `BaseView` will be renamed `DataView(BaseView)` since it mainly exists to introduce the handy `.data()` abstraction.\r\n\r\nSo...\r\n\r\n* `AsgiView` - has `.asgi()` method, extends Sanic `HTTPMethodView` (for the moment)\r\n* `BaseView(AsgiView)` - defines utility methods currently on `RenderMixin`\r\n* `IndexView(BaseView)` - the current `IndexView`\r\n* `DataView(BaseView)` - defines the utilities currently on `BaseView`, including `data()`\r\n* Everything else subclasses `DataView`\r\n\r\n## Extract routing logic out into a new `DatasetteView`\r\n\r\nI considered calling this `RouteView`, but one of the goals of this project is to allow other ASGI apps to import Datasette itself and reuse it as its own ASGI function.\r\n\r\nSo `DatasetteView` will subclass `BaseView` and will do all of the routing logic. That logic currently lives here:\r\n\r\nhttps://github.com/simonw/datasette/blob/aa911122feab13f8e65875c98edb00fd3832b7b8/datasette/app.py#L594-L640\r\n\r\n## For tests: Implement a version of app_client.get() that calls ASGI instead\r\n\r\nAlmost all of the unit tests currently use `app_client.get(\"/path...\")`. I want to be able to run tests against both ASGI and existing-Sanic, so for the moment I'm going to teach `app_client.get()` to use ASGI instead but only in the presence of a new environment variable. I can then have Travis run the tests twice - once with that environement variable and once without.\r\n\r\n## Make datasette serve --asgi run ASGI and uvicorn\r\n\r\nUvicorn supports Python 3.5 again as of https://github.com/encode/uvicorn/issues/330 - so it's going to be the new dependency for Datasette. \r\n\r\n## Do some comparative testing of ASGI and non-ASGI\r\n\r\nJust some sanity checking to make sure there aren't any weird issues.\r\n\r\n## Final step: refactor out Sanic\r\n\r\nHopefully this will just involve changes being made to the AsgiView base class, since that subclasses Sanic `HTTPMethodView`.\r\n\r\nBonus: It looks like dropping Sanic as a dependency in favour of Uvicorn should give us Windows support! https://github.com/encode/uvicorn/issues/82\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 324188953, "label": "Port Datasette to ASGI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/272#issuecomment-502393267", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/272", "id": 502393267, "node_id": "MDEyOklzc3VlQ29tbWVudDUwMjM5MzI2Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-15T19:28:27Z", "updated_at": "2019-06-15T19:28:27Z", "author_association": "OWNER", "body": "I'll probably revert 9fdb47ca952b93b7b60adddb965ea6642b1ff523 from https://github.com/simonw/datasette/issues/272#issuecomment-494192779 since I won't need it now that ASGI is getting `raw_path` support.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 324188953, "label": "Port Datasette to ASGI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/272#issuecomment-502394420", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/272", "id": 502394420, "node_id": "MDEyOklzc3VlQ29tbWVudDUwMjM5NDQyMA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-15T19:45:46Z", "updated_at": "2019-06-15T19:45:46Z", "author_association": "OWNER", "body": "For reference, here's some WIP code I wrote last year against the old ASGI 2 spec: https://github.com/simonw/datasette/commit/4fd36ba2f3f91da7258859808616078e3464fb97", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 324188953, "label": "Port Datasette to ASGI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/272#issuecomment-502395689", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/272", "id": 502395689, "node_id": "MDEyOklzc3VlQ29tbWVudDUwMjM5NTY4OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-15T20:05:26Z", "updated_at": "2019-06-15T20:05:26Z", "author_association": "OWNER", "body": "For the routing component: I'm going to base my implementation on the one from Django Channels.\r\n\r\nhttps://github.com/django/channels/blob/507cb54fcb36df63282dd19653ea743036e7d63c/channels/routing.py#L123-L149\r\n\r\nDocumented here: https://channels.readthedocs.io/en/latest/topics/routing.html#urlrouter\r\n\r\nParticularly relevant: my view classes need access to the components that were already parsed out of the URL by the router. I'm going to copy the Django Channels mechanism of stashing those in `scope[\"url_route\"][\"kwargs\"]`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 324188953, "label": "Port Datasette to ASGI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/272#issuecomment-502401078", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/272", "id": 502401078, "node_id": "MDEyOklzc3VlQ29tbWVudDUwMjQwMTA3OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-15T21:35:26Z", "updated_at": "2019-06-15T21:35:26Z", "author_association": "OWNER", "body": "Started sketching out the router in the `asgi` branch: https://github.com/simonw/datasette/commit/7cdc55c6836fe246b1ca8a13a965a39991c9ffec", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 324188953, "label": "Port Datasette to ASGI"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/507#issuecomment-502402586", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/507", "id": 502402586, "node_id": "MDEyOklzc3VlQ29tbWVudDUwMjQwMjU4Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-15T22:00:14Z", "updated_at": "2019-06-15T22:00:14Z", "author_association": "OWNER", "body": "I need to find a good tool for taking screenshots on OSX that are reliably the same dimension across multiple sessions. Maybe in Firefox?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 455852801, "label": "Every datasette plugin on the ecosystem page should have a screenshot"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/509#issuecomment-502393573", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/509", "id": 502393573, "node_id": "MDEyOklzc3VlQ29tbWVudDUwMjM5MzU3Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2019-06-15T19:32:56Z", "updated_at": "2019-06-15T19:32:56Z", "author_association": "OWNER", "body": "Experimental exploratory patch:\r\n```diff\r\ndiff --git a/datasette/app.py b/datasette/app.py\r\nindex 2ef7da4..ca51866 100644\r\n--- a/datasette/app.py\r\n+++ b/datasette/app.py\r\n@@ -164,8 +164,10 @@ class Datasette:\r\n is_memory = True\r\n is_mutable = path not in self.immutables\r\n db = Database(self, path, is_mutable=is_mutable, is_memory=is_memory)\r\n+ i = 1\r\n if db.name in self.databases:\r\n- raise Exception(\"Multiple files with same stem: {}\".format(db.name))\r\n+ db.stem = db.name + \"-\" + str(i)\r\n+ i += 1\r\n self.databases[db.name] = db\r\n self.cache_headers = cache_headers\r\n self.cors = cors\r\ndiff --git a/datasette/database.py b/datasette/database.py\r\nindex e491577..75c8681 100644\r\n--- a/datasette/database.py\r\n+++ b/datasette/database.py\r\n@@ -14,6 +14,8 @@ from .inspect import inspect_hash\r\n \r\n \r\n class Database:\r\n+ stem = None\r\n+\r\n def __init__(self, ds, path=None, is_mutable=False, is_memory=False):\r\n self.ds = ds\r\n self.path = path\r\n@@ -73,6 +75,8 @@ class Database:\r\n def name(self):\r\n if self.is_memory:\r\n return \":memory:\"\r\n+ elif self.stem:\r\n+ return self.stem\r\n else:\r\n return Path(self.path).stem\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": 456568880, "label": "Support opening multiple databases with the same stem"}, "performed_via_github_app": null}