home / docs / sections

sections: internals:datasette-check-visibility

This data as json

id page ref title content breadcrumbs references
internals:datasette-check-visibility internals datasette-check-visibility await .check_visibility(actor, action, resource=None) actor - dictionary The authenticated actor. This is usually request.actor . action - string The name of the action that is being permission checked. resource - Resource object, optional The resource being checked, as a Resource object such as DatabaseResource(database=...) , TableResource(database=..., table=...) , or QueryResource(database=..., query=...) . Only some permissions apply to a resource. This convenience method can be used to answer the question "should this item be considered private, in that it is visible to me but it is not visible to anonymous users?" It returns a tuple of two booleans, (visible, private) . visible indicates if the actor can see this resource. private will be True if an anonymous user would not be able to view the resource. This example checks if the user can access a specific table, and sets private so that a padlock icon can later be displayed: from datasette.resources import TableResource visible, private = await datasette.check_visibility( request.actor, action="view-table", resource=TableResource(database=database, table=table), ) ["Internals for plugins", "Datasette class"] []
Powered by Datasette · Queries took 2.09ms