New pattern for views that return either JSON or HTML, available for plugins
See original GitHub issueCan be part of #870 - refactoring existing views to use register_routes()
.
I’m going to put the new
check_permissions()
method onBaseView
as well. If I want that method to be available to plugins I can do so by turning thatBaseView
class into a documented API that plugins are encouraged to use themselves. _Originally posted by @simonw in https://github.com/simonw/datasette/issues/832#issuecomment-651995453_
Issue Analytics
- State:
- Created 3 years ago
- Comments:26 (25 by maintainers)
Top Results From Across the Web
Internals for plugins — Datasette documentation
If neither metadata.json nor any of the plugins provide an answer to the permission query the default argument will be returned.
Read more >Connect REST Interface - Confluent Documentation
Currently the REST API only supports application/json as both the request ... Create a new connector, returning the current connector info if successful....
Read more >Views and templates — Phoenix v1.6.15 - HexDocs
Views are about data presentation. Given a bag of data, the view's purpose is to present that in a meaningful way given some...
Read more >JSON - Smartling Help Center
Content Parsing. JSON files are based on name and value pairs. For example, in this basic JSON file, “button1” is the name and...
Read more >10 REST 5.2.5 - The Grails Framework
Simply by adding the Resource transformation and specifying a URI, your domain class will automatically be available as a REST resource in either...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I came up with a slightly wild idea for this that would involve pytest-style dependency injection.
Prototype here: https://gist.github.com/simonw/496b24fdad44f6f8b7237fe394a0ced7
Copying from my private notes:
On revisiting https://gist.github.com/simonw/281eac9c73b062c3469607ad86470eb2 a few months later I’m having second thoughts about using
@inject
on themain()
method.But I still like the pattern as a way to resolve more complex cases like “to generate GeoJSON of the expanded view with labels, the label expansion code needs to run once at some before the GeoJSON formatting code does”.
So I’m going to stick with it a tiny bit longer, but maybe try to make it a lot more explicit when it’s going to happen rather than having the main view methods themselves also use async DI.