Skip to content

Actions

How to write and call actions is covered in the Actions guide.

dachshund.registry

action

action(name, **kwargs)

Register an action, on the default dashboard.

Takes what Dashboard.action does.

Example
import dachshund


@dachshund.action("block_user", label="Block", confirm=True)
def block_user(ctx: dachshund.Context, user_id: str) -> None: ...
Source code in dachshund/registry.py
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
def action(
    name: str, **kwargs: Any
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
    """Register an action, on the default dashboard.

    Takes what [Dashboard.action][dachshund.registry.Dashboard.action] does.

    ## Example

    ```python
    import dachshund


    @dachshund.action("block_user", label="Block", confirm=True)
    def block_user(ctx: dachshund.Context, user_id: str) -> None: ...
    ```
    """
    return default().action(name, **kwargs)

dachshund.actions.Action dataclass

Action(name, handler, label=None, confirm=False, public=False)

A handler the dashboard's UI can invoke.

Example

Action("block_user", block_user, label="Block", confirm=True)

name instance-attribute

name

handler instance-attribute

handler

label class-attribute instance-attribute

label = None

confirm class-attribute instance-attribute

confirm = False

public class-attribute instance-attribute

public = False