kopia lustrzana https://gitlab.com/marnanel/chapeau
1.5 KiB
1.5 KiB
Kepi's models
Kepi uses django-polymorphic models to represent ActivityPub messages.
The superclass is Object
. It has some important subclasses:
Activity
is the superclass of all activities, such asCreate
andLike
.Actor
is the superclass of all actors, such asPerson
.Item
is the superclass of Notes and so on. (These don't have a superclass other thanObject
in the spec, soItem
is a name you'll only see here.)
Object
used to be called Thing
, in case people confused it
with Python's own object
class. But now it's Object
with a
capital O. You will still find some references to it as "thing", though.
Object
s represent ActivityPub types, which are dicts. Therefore,
Object
s have fields. The fields may be stored in various ways:
- As a field of the
Object
itself, prefixed withf_
. The prefix allows us to have fields such astype
, which is a Python reserved word. - In a
ThingField
which refers to theObject
. The values of aThingField
are stored as JSON, so they can be arbitrary. - Anything else the
Object
makes up, as long as it can provide it to accessors.
Object
fields may be read and written via subscripting (e.g.
foo['type']
. You may append flags to the argument
separated by double underscores. I will document these flags
at some point.
All Object
s have an activity_form
property which
returns their representation as a dict.