mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Add check to subscription handler for deleted objects.
This commit is contained in:
parent
24c5ddecab
commit
bc3f3ea586
1 changed files with 17 additions and 6 deletions
|
|
@ -453,8 +453,10 @@ class SubscriptionHandler(object):
|
|||
self._cache = None
|
||||
|
||||
def _recache(self):
|
||||
self._cache = {player : True for player in self.obj.db_subscriptions.all()}
|
||||
self._cache.update({obj : True for obj in self.obj.db_object_subscriptions.all()})
|
||||
self._cache = {player: True for player in self.obj.db_subscriptions.all()
|
||||
if hasattr(player, 'pk') and player.pk}
|
||||
self._cache.update({obj: True for obj in self.obj.db_object_subscriptions.all()
|
||||
if hasattr(obj, 'pk') and obj.pk})
|
||||
|
||||
def has(self, entity):
|
||||
"""
|
||||
|
|
@ -546,14 +548,23 @@ class SubscriptionHandler(object):
|
|||
are puppeted by an online player.
|
||||
"""
|
||||
subs = []
|
||||
recache_needed = False
|
||||
for obj in self.all():
|
||||
if hasattr(obj, 'player'):
|
||||
if not obj.player:
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
try:
|
||||
if hasattr(obj, 'player'):
|
||||
if not obj.player:
|
||||
continue
|
||||
obj = obj.player
|
||||
if not obj.is_connected:
|
||||
continue
|
||||
obj = obj.player
|
||||
if not obj.is_connected:
|
||||
except ObjectDoesNotExist:
|
||||
# a subscribed object has already been deleted. Mark that we need a recache and ignore it
|
||||
recache_needed = True
|
||||
continue
|
||||
subs.append(obj)
|
||||
if recache_needed:
|
||||
self._recache()
|
||||
return subs
|
||||
|
||||
def clear(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue