Skip to content

Reconsider how _actor_X magic parameter deals with missing values #886

Open

Description

@simonw

I had to build a custom _actorornull prefix for datasette-saved-queries:

def actorornull(key, request):
    if request.actor is None:
        return None
    return request.actor.get(key)


@hookimpl
def register_magic_parameters():
    return [
        ("actorornull", actorornull),
    ]

Maybe the actor magic in Datasette core should do that out of the box?

def actor(key, request):
if request.actor is None:
raise KeyError
return request.actor[key]

Activity

  1. added this to the Datasette 0.46 milestone on Jul 2, 2020
  2. simonw commented on Jul 2, 2020

    @simonw
    OwnerAuthor

    A common error with this (and other) magic parameters is for the database query to result in the following:

    You did not supply a value for binding 3.
    

    This is a pretty crufty error. I'm inclined to say that ANY missing or invalid magic parameter should be treated as a None value instead.

  3. simonw commented on Jul 2, 2020

    @simonw
    OwnerAuthor

    In investigating this I'm not convinced 500 errors are being correctly raised by errors in canned writable queries.

  4. removed this from the Datasette 0.49 milestone on Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions