coarnotify.core.activitystreams2¶
This module contains everything COAR Notify needs to know about ActivityStreams 2.0 https://www.w3.org/TR/activitystreams-core/
It provides knowledge of the essential AS properties and types, and a class to wrap ActivityStreams objects and provide a simple interface to work with them.
NOTE this is not a complete implementation of AS 2.0, it is only what is required to work with COAR Notify patterns.
Attributes¶
Namespace for Actvitity Streams, to be used to construct namespaced properties used in COAR Notify Patterns |
|
The sub-list of ActivityStreams types that are also objects in AS 2.0 |
Classes¶
A simple wrapper around an ActivityStreams dictionary object |
|
List of all the Activity Streams types COAR Notify may use. |
|
ActivityStreams 2.0 properties used in COAR Notify Patterns |
Module Contents¶
- class coarnotify.core.activitystreams2.ActivityStream(raw: dict = None)¶
A simple wrapper around an ActivityStreams dictionary object
Construct it with a python dictionary that represents an ActivityStreams object, or without to create a fresh, blank object.
- Parameters:
raw – the raw ActivityStreams object, as a dictionary
- get_property(property: str | tuple[str, str] | tuple[str, tuple[str, str]])¶
Get an arbitrary property on the object. The property name can be one of:
A simple string with the property name
A tuple of the property name and the full namespace
("name", "http://example.com/ns")
A tuple containing the property name and another tuple of the short name and the full namespace
("name", ("as", "http://example.com/ns"))
- Parameters:
property – the property name
- Returns:
the value of the property, or None if it does not exist
- set_property(property: str | tuple[str, str] | tuple[str, tuple[str, str]], value)¶
Set an arbitrary property on the object. The property name can be one of:
A simple string with the property name
A tuple of the property name and the full namespace
("name", "http://example.com/ns")
A tuple containing the property name and another tuple of the short name and the full namespace
("name", ("as", "http://example.com/ns"))
- Parameters:
property – the property name
value – the value to set
- to_jsonld() dict ¶
Get the activity stream as a JSON-LD object
- Returns:
- property context¶
The json-ld context of the ActivityStream
- property doc: dict¶
The internal dictionary representation of the ActivityStream, without the json-ld context
- class coarnotify.core.activitystreams2.ActivityStreamsTypes¶
List of all the Activity Streams types COAR Notify may use.
Note that COAR Notify also has its own custom types and they are defined in
coarnotify.models.notify.NotifyTypes
- ACCEPT = 'Accept'¶
- ACTIVITY = 'Activity'¶
- ANNOUNCE = 'Announce'¶
- APPLICATION = 'Application'¶
- ARTICLE = 'Article'¶
- AUDIO = 'Audio'¶
- COLLECTION = 'Collection'¶
- COLLECTION_PAGE = 'CollectionPage'¶
- DOCUMENT = 'Document'¶
- EVENT = 'Event'¶
- FLAG = 'Flag'¶
- GROUP = 'Group'¶
- IMAGE = 'Image'¶
- INTRANSITIVE_ACTIVITY = 'IntransitiveActivity'¶
- NOTE = 'Note'¶
- OBJECT = 'Object'¶
- OFFER = 'Offer'¶
- ORDERED_COLLECTION = 'OrderedCollection'¶
- ORDERED_COLLECTION_PAGE = 'OrderedCollectionPage'¶
- ORGANIZATION = 'Organization'¶
- PAGE = 'Page'¶
- PERSON = 'Person'¶
- PLACE = 'Place'¶
- PROFILE = 'Profile'¶
- QUESTION = 'Question'¶
- REJECT = 'Reject'¶
- RELATIONSHIP = 'Relationship'¶
- SERVICE = 'Service'¶
- TENTATIVE_ACCEPT = 'TentativeAccept'¶
- TENTATIVE_REJECT = 'TentativeReject'¶
- TOMBSTONE = 'Tombstone'¶
- UNDO = 'Undo'¶
- VIDEO = 'Video'¶
- class coarnotify.core.activitystreams2.Properties¶
ActivityStreams 2.0 properties used in COAR Notify Patterns
These are provided as tuples, where the first element is the property name, and the second element is the namespace.
These are suitbale to be used as property names in all the property getters/setters in the notify pattern objects and in the validation configuration.
- ACTOR¶
actor
property
- CONTEXT¶
context
property
- ID¶
id
property
- IN_REPLY_TO¶
inReplyTo
property
- OBJECT¶
object
property
- OBJECT_TRIPLE¶
as:object
property
- ORIGIN¶
origin
property
- RELATIONSHIP_TRIPLE¶
as:relationship
property
- SUBJECT_TRIPLE¶
as:subject
property
- SUMMARY¶
summary
property
- TARGET¶
target
property
- TYPE¶
type
property
- coarnotify.core.activitystreams2.ACTIVITY_STREAMS_NAMESPACE = 'https://www.w3.org/ns/activitystreams'¶
Namespace for Actvitity Streams, to be used to construct namespaced properties used in COAR Notify Patterns
- coarnotify.core.activitystreams2.ACTIVITY_STREAMS_OBJECTS¶
The sub-list of ActivityStreams types that are also objects in AS 2.0