Models

Models for the dasf-broker-django app.

Models:

BrokerMessage(*args, **kwargs)

A message sent to the broker.

BrokerTopic(*args, **kwargs)

A topic for producing and consuming requests via websocket

ResponseTopic(*args, **kwargs)

A topic that accepts responses for messages.

Classes:

BrokerTopicManager(*args, **kwargs)

A manager for broker topics.

BrokerTopicQuerySet([model, query, using, hints])

A queryset for broker topics.

class dasf_broker.models.BrokerMessage(*args, **kwargs)

Bases: Model

A message sent to the broker.

Miscellaneous:

DoesNotExist

MultipleObjectsReturned

Model Fields:

content

A wrapper for a deferred-loading field.

context

A wrapper for a deferred-loading field.

date_created

A wrapper for a deferred-loading field.

id

A wrapper for a deferred-loading field.

message_id

A wrapper for a deferred-loading field.

topic

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

Attributes:

delivered_to

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

delivered_to_all

Test if the message has been delivered to all consumers.

is_response

Is this message a response to a DASF request?

objects

responsetopic_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

topic_id

user_id

Methods:

get_next_by_date_created(*[, field, is_next])

get_previous_by_date_created(*[, field, is_next])

send()

Send the message via the websocket.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

content

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

context

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

date_created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

delivered_to

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

property delivered_to_all: bool

Test if the message has been delivered to all consumers.

get_next_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=True, **kwargs)
get_previous_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property is_response: bool

Is this message a response to a DASF request?

message_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
responsetopic_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

send()

Send the message via the websocket.

topic

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

topic_id
user

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_id
class dasf_broker.models.BrokerTopic(*args, **kwargs)

Bases: Model

A topic for producing and consuming requests via websocket

Miscellaneous:

DoesNotExist

MultipleObjectsReturned

Classes:

StoreMessageChoices(value)

Choices for storing messages.

Attributes:

availability

Get the online/offline status for the topic.

brokermessage_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

consumers

effective_store_messages

Get the store message rule for this topic.

is_response_topic

Is this topic a responsetopic?

objects

producers

responsetopic

Accessor to the related object on the reverse side of a one-to-one relation.

responsetopics

Accessor to the related objects manager on the reverse side of a many-to-one relation.

status_viewers

Methods:

build_websocket_url(request[, route])

create_and_send_message(user, content)

Create and send a message for the user

get_next_by_date_created(*[, field, is_next])

get_outstanding_messages([user])

Get the messages that still need to be send.

get_previous_by_date_created(*[, field, is_next])

get_store_messages_display(*[, field])

get_websocket_url(request)

Get the websocket url for this topic.

ping()

Create a ping message and send it to the consumer.

Model Fields:

date_created

A wrapper for a deferred-loading field.

garbage_collect_on

A wrapper for a deferred-loading field.

id

A wrapper for a deferred-loading field.

is_public

A wrapper for a deferred-loading field.

last_ping

A wrapper for a deferred-loading field.

last_pong

A wrapper for a deferred-loading field.

slug

A wrapper for a deferred-loading field.

store_messages

A wrapper for a deferred-loading field.

supports_dasf

A wrapper for a deferred-loading field.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

class StoreMessageChoices(value)

Bases: TextChoices

Choices for storing messages.

Attributes:

CACHE

CACHEALL

DISABLED

STORE

CACHE = 'cache'
CACHEALL = 'cacheall'
DISABLED = 'disabled'
STORE = 'store'
availability

Get the online/offline status for the topic.

This value can be True, False or None:

None

The status is unknown. This occurs when the last ping was more than two minutes ago or the topic has never, been pinged.

False

The was no pong yet or the last pong was before the last ping and the last ping was less than two minutes ago.

True

The topic is online, i.e. we received a pong after the last ping and the last ping was less then two minutes ago.

brokermessage_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

classmethod build_websocket_url(request, route: str | None = None) str
property consumers: models.QuerySet[User]
create_and_send_message(user: User, content: Dict)

Create and send a message for the user

date_created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property effective_store_messages: StoreMessageChoices

Get the store message rule for this topic.

garbage_collect_on

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=True, **kwargs)
get_outstanding_messages(user: User | None = None) models.QuerySet[BrokerMessage]

Get the messages that still need to be send.

Parameters:

user (Optional[User]) – The user for whom to send the messages. If None, the messages will be returned that have not yet been acknowledged at all.

Returns:

A QuerySet of messages

Return type:

models.QuerySet[BrokerMessage]

get_previous_by_date_created(*, field=<django.db.models.fields.DateTimeField: date_created>, is_next=False, **kwargs)
get_store_messages_display(*, field=<django.db.models.fields.CharField: store_messages>)
get_websocket_url(request) str

Get the websocket url for this topic.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_public

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property is_response_topic: bool

Is this topic a responsetopic?

last_ping

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_pong

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <dasf_broker.models.BrokerTopicManager object>
ping()

Create a ping message and send it to the consumer.

property producers: models.QuerySet[User]
responsetopic

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

responsetopics

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

slug

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property status_viewers: models.QuerySet[User]
store_messages

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

supports_dasf

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class dasf_broker.models.BrokerTopicManager(*args, **kwargs)

Bases: ManagerFromBrokerTopicQuerySet

A manager for broker topics.

class dasf_broker.models.BrokerTopicQuerySet(model=None, query=None, using=None, hints=None)

Bases: QuerySet

A queryset for broker topics.

Methods:

filter_offline(*args)

Query all online broker topics.

filter_online(*args, **kwargs)

Query all online broker topics.

filter_unknown_availability(*args)

Query all topics where the availability is unknown.

filter_offline(*args)

Query all online broker topics.

filter_online(*args, **kwargs)

Query all online broker topics.

filter_unknown_availability(*args)

Query all topics where the availability is unknown.

class dasf_broker.models.ResponseTopic(*args, **kwargs)

Bases: BrokerTopic

A topic that accepts responses for messages.

Miscellaneous:

DoesNotExist

MultipleObjectsReturned

Model Fields:

brokertopic_ptr

Accessor to the related object on the forward side of a one-to-one relation.

is_response_for

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

Attributes:

brokertopic_ptr_id

is_response_for_id

is_response_topic

Is this topic a responsetopic?

source_messages

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

exception DoesNotExist

Bases: DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

brokertopic_ptr: BrokerTopic

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

brokertopic_ptr_id
is_response_for

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

is_response_for_id
property is_response_topic: bool

Is this topic a responsetopic?

source_messages

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.