{"html_url": "https://github.com/simonw/datasette/issues/943#issuecomment-675787416", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/943", "id": 675787416, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTc4NzQxNg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-19T00:42:38Z", "updated_at": "2020-08-19T00:42:38Z", "author_association": "OWNER", "body": "I just realised that this mechanism is kind of like being able to use microservices - make API calls within your application - except that everything runs in the same process against SQLite databases so calls will be _lightning fast_.\r\n\r\nIt also means that a plugin can add a new internal API to Datasette that's accessible to other plugins by registering a new route 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": 681375466, "label": "await datasette.client.get(path) mechanism for executing internal requests"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/943#issuecomment-675788203", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/943", "id": 675788203, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTc4ODIwMw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-19T00:46:08Z", "updated_at": "2020-08-19T00:46:23Z", "author_association": "OWNER", "body": "Also fun: the inevitable plugin that exposes this to the template language - so Datasette templates can stitch together data from multiple other internal API calls. Fun way to take advantage of `async` support in Jinja.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 681375466, "label": "await datasette.client.get(path) mechanism for executing internal requests"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/943#issuecomment-675884980", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/943", "id": 675884980, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTg4NDk4MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-19T06:44:26Z", "updated_at": "2020-08-19T06:44:26Z", "author_association": "OWNER", "body": "Need to decide what to do about JSON responses.\r\n\r\nWhen called from a template it's likely the intent will be to further loop through the JSON data returned. It would be annoying to have to run `json.loads` here.\r\n\r\nMaybe a `.get_json()` method then? Or even return a response that has `.json()` and `.text` similar to `httpx` - or just return an `httpx` response.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 681375466, "label": "await datasette.client.get(path) mechanism for executing internal requests"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/943#issuecomment-675889551", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/943", "id": 675889551, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTg4OTU1MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-19T06:56:06Z", "updated_at": "2020-08-19T06:56:17Z", "author_association": "OWNER", "body": "I'm leaning towards defaulting to JSON as the requested format - you can pass `format=\"html\"` if you want HTML.\r\n\r\nBut weird that it's different from the web UI.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 681375466, "label": "await datasette.client.get(path) mechanism for executing internal requests"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/943#issuecomment-675889865", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/943", "id": 675889865, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTg4OTg2NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-19T06:57:00Z", "updated_at": "2020-08-19T06:57:00Z", "author_association": "OWNER", "body": "Maybe `.get` vs `.get_html`?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 681375466, "label": "await datasette.client.get(path) mechanism for executing internal requests"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/944#issuecomment-675829942", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/944", "id": 675829942, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTgyOTk0Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-19T03:27:25Z", "updated_at": "2020-08-19T03:27:25Z", "author_association": "OWNER", "body": "I created a template file called `templates/pages/museums/{slug}.html` and used the debugger to see if Jinja could see it. This worked:\r\n```\r\n(Pdb) self.ds.jinja_env.list_templates()\r\n['500.html', '_codemirror.html', '_codemirror_foot.html', '_description_source_license.html', '_footer.html',\r\n'_table.html', 'allow_debug.html', 'base.html', 'database.html', 'default:500.html', 'default:_codemirror.html',\r\n'default:_codemirror_foot.html', 'default:_description_source_license.html', 'default:_footer.html',\r\n'default:_table.html', 'default:allow_debug.html', 'default:base.html', 'default:database.html',\r\n'default:index.html', 'default:logout.html', 'default:messages_debug.html', 'default:patterns.html',\r\n'default:permissions_debug.html', 'default:query.html', 'default:row.html', 'default:show_json.html',\r\n'default:table.html', 'forbidden.html', 'index.html', 'logout.html', 'messages_debug.html',\r\n'pages/about.html', 'pages/museums/{slug}.html', 'patterns.html', 'permissions_debug.html',\r\n'query.html', 'row.html', 'show_json.html', 'table.html']\r\n```\r\nThe `pages/museums/{slug}.html` template is in that list.\r\n\r\nHere's the implementation of that `list_templates()` method - it does some filesystem walking so it may be a bit expensive to run it on every request: https://github.com/pallets/jinja/blob/ca8b0b0287e320fe1f4a74f36910ef7ae3303d99/src/jinja2/loaders.py#L197-L212\r\n\r\nBut caching it would be pretty easy - either until the server is restarted or as an in-memory cache for a few seconds.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 681516976, "label": "Path parameters for custom pages"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/944#issuecomment-675830678", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/944", "id": 675830678, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NTgzMDY3OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-19T03:30:10Z", "updated_at": "2020-08-19T03:30:10Z", "author_association": "OWNER", "body": "These templates will need a way to raise a 404 - so that if the template itself is deciding if the page exists (for example using `datasette-template-sql` or the proposed `datasette.get()` method from #943 or the `graphql()` template function in https://github.com/simonw/datasette-graphql/issues/50) it can return a regular 404 page.\r\n\r\nThis can imitate the `custom_redirect()` function from https://docs.datasette.io/en/stable/custom_templates.html#custom-redirects:\r\n```html+jinja\r\n{{ custom_redirect(\"https://github.com/simonw/datasette\", 301) }}\r\n```\r\nIt could be as simple as this:\r\n```\r\n{{ raise_404(\"Museum not found\") }}\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 681516976, "label": "Path parameters for custom pages"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/945#issuecomment-676556377", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/945", "id": 676556377, "node_id": "MDEyOklzc3VlQ29tbWVudDY3NjU1NjM3Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-19T17:21:16Z", "updated_at": "2020-08-19T17:21:16Z", "author_association": "OWNER", "body": "Documented here: https://docs.datasette.io/en/latest/plugins.html#installing-plugins", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 682005535, "label": "datasette install -U for upgrading packages"}, "performed_via_github_app": null}