Skip to content

muck_out.cattle_grid

This package contains helper methods allowing one to write nicer code in a combination of cattle_grid, muck_out, and magic injection.

Examples

We now illustrate the usage of these methods

Fetch

The annotations starting with fetch are available whenever, you have a configured broker and activity exchange. Their usage is as

async def my_method(fetcher: FetchObject):
    obj = await fetcher(
        "http://my.example/actor/id",
        "http://other.example/object/id"
    )

We note that the actor id must belong to an actor managed by cattle_grid.

Parsed

The Parsed- annotations are used in processing, i.e.

@subscribe("some_routing_key")
async def process_actor(actor: ParsedActor):
    ...

where one is assumed to process messages of type ActivityMessage, or something inheriting from it.

Transform

@extension.transform(inputs=["parsed"], outputs=[...])
async def transform(
    actor: TransformedActor
) -> dict[str, Any]:
    ...

FetchActivity module-attribute

FetchActivity = Annotated[
    Callable[[str, str], Awaitable[Activity | None]],
    Depends(fetch_activity_builder),
]

Returns the activity after fetching it

FetchActor module-attribute

FetchActor = Annotated[
    Callable[[str, str], Awaitable[Actor | None]],
    Depends(fetch_actor_builder),
]

Returns the actor after fetching it

FetchCollection module-attribute

FetchCollection = Annotated[
    Callable[[str, str], Awaitable[Collection | None]],
    Depends(fetch_collection_builder),
]

Returns the collection after fetching it

FetchObject module-attribute

FetchObject = Annotated[
    Callable[[str, str], Awaitable[Object | None]],
    Depends(fetch_object_builder),
]

Returns the object after fetching it

ParsedActivity module-attribute

ParsedActivity = Annotated[
    Activity | None, Depends(get_activity)
]

Returns the parsed activity from the muck_out extension.

This dependency works for methods that would normally receive a ActivityMessage, e.g. the incoming.* and outgoing.* subscriber of cattle_grid.

ParsedActor module-attribute

ParsedActor = Annotated[Actor | None, Depends(get_actor)]

Returns the parsed actor from the muck_out extension.

This dependency works for methods that would normally receive a ActivityMessage, e.g. the incoming.* and outgoing.* subscriber of cattle_grid.

ParsedCollection module-attribute

ParsedCollection = Annotated[
    Collection | None, Depends(get_collection)
]

Returns the parsed collection from the muck_out extension.

This dependency works for methods that would normally receive a ActivityMessage, e.g. the incoming.* and outgoing.* subscriber of cattle_grid.

ParsedEmbeddedObject module-attribute

ParsedEmbeddedObject = Annotated[
    Object | None, Depends(get_embedded_object)
]

Returns the parsed embededed object from an activity from the muck_out extension.

This dependency works for methods that would normally receive a ActivityMessage, e.g. the incoming.* and outgoing.* subscriber of cattle_grid.

ParsedObject module-attribute

ParsedObject = Annotated[Object | None, Depends(get_object)]

Returns the parsed object from the muck_out extension.

This dependency works for methods that would normally receive a ActivityMessage, e.g. the incoming.* and outgoing.* subscriber of cattle_grid.

TransformedActivity module-attribute

TransformedActivity = Annotated[
    Activity | None, Depends(transform_activity)
]

Inside of a running transformer, returns the Activity as transformed by muck_out

TransformedActor module-attribute

TransformedActor = Annotated[
    Actor | None, Depends(transform_actor)
]

Inside of a running transformer, returns the Actor as transformed by muck_out

TransformedCollection module-attribute

TransformedCollection = Annotated[
    Collection | None, Depends(transform_collection)
]

Inside of a running transformer, returns the Collection as transformed by muck_out

TransformedEmbeddedObject module-attribute

TransformedEmbeddedObject = Annotated[
    Object | None, Depends(transform_embedded_object)
]

Inside of a running transformer, returns the EmbeddedObject as transformed by muck_out

TransformedObject module-attribute

TransformedObject = Annotated[
    Object | None, Depends(transform_object)
]

Inside of a running transformer, returns the Object as transformed by muck_out