Fixes in SubscriptionHandler; return subs ordered by pk.

This commit is contained in:
Griatch 2023-10-01 10:49:42 +02:00 committed by holl0wstar
parent e28f9dd3c4
commit 26a804ca1f
2 changed files with 16 additions and 12 deletions

View file

@ -7,7 +7,6 @@ import re
from django.contrib.contenttypes.models import ContentType
from django.urls import reverse
from django.utils.text import slugify
from evennia.comms.managers import ChannelManager
from evennia.comms.models import ChannelDB
from evennia.typeclasses.models import TypeclassBase
@ -188,7 +187,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
# display listening subscribers in bold
string = ", ".join(
[
account.key if account not in listening else "|w%s|n" % account.key
account.key if account not in listening else f"|w{account.key}|n"
for account in subs
]
)

View file

@ -21,7 +21,6 @@ necessary to easily be able to delete connections on the fly).
from django.conf import settings
from django.db import models
from django.utils import timezone
from evennia.comms import managers
from evennia.locks.lockhandler import LockHandler
from evennia.typeclasses.models import TypedObject
@ -104,8 +103,10 @@ class Msg(SharedMemoryModel):
null=True,
blank=True,
db_index=True,
help_text="Identifier for single external sender, for use with senders "
"not represented by a regular database model.",
help_text=(
"Identifier for single external sender, for use with senders "
"not represented by a regular database model."
),
)
db_receivers_accounts = models.ManyToManyField(
@ -137,8 +138,10 @@ class Msg(SharedMemoryModel):
null=True,
blank=True,
db_index=True,
help_text="Identifier for single external receiver, for use with recievers "
"not represented by a regular database model.",
help_text=(
"Identifier for single external receiver, for use with recievers "
"not represented by a regular database model."
),
)
# header could be used for meta-info about the message if your system needs
@ -167,8 +170,10 @@ class Msg(SharedMemoryModel):
db_tags = models.ManyToManyField(
Tag,
blank=True,
help_text="tags on this message. Tags are simple string markers to "
"identify, group and alias messages.",
help_text=(
"tags on this message. Tags are simple string markers to "
"identify, group and alias messages."
),
)
# Database manager
@ -518,7 +523,7 @@ class TempMsg:
# ------------------------------------------------------------
class SubscriptionHandler(object):
class SubscriptionHandler:
"""
This handler manages subscriptions to the
channel and hides away which type of entity is
@ -540,13 +545,13 @@ class SubscriptionHandler(object):
def _recache(self):
self._cache = {
account: True
for account in self.obj.db_account_subscriptions.all()
for account in self.obj.db_account_subscriptions.all().order_by("pk")
if hasattr(account, "pk") and account.pk
}
self._cache.update(
{
obj: True
for obj in self.obj.db_object_subscriptions.all()
for obj in self.obj.db_object_subscriptions.all().order_by("pk")
if hasattr(obj, "pk") and obj.pk
}
)