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.
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
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
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
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
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
Inside of a running transformer, returns the Activity as transformed by muck_out
TransformedActor
module-attribute
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
Inside of a running transformer, returns the EmbeddedObject as transformed by muck_out