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
|
self._cache = None
|
||||||
|
|
||||||
def _recache(self):
|
def _recache(self):
|
||||||
self._cache = {player : True for player in self.obj.db_subscriptions.all()}
|
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()})
|
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):
|
def has(self, entity):
|
||||||
"""
|
"""
|
||||||
|
|
@ -546,14 +548,23 @@ class SubscriptionHandler(object):
|
||||||
are puppeted by an online player.
|
are puppeted by an online player.
|
||||||
"""
|
"""
|
||||||
subs = []
|
subs = []
|
||||||
|
recache_needed = False
|
||||||
for obj in self.all():
|
for obj in self.all():
|
||||||
if hasattr(obj, 'player'):
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
if not obj.player:
|
try:
|
||||||
|
if hasattr(obj, 'player'):
|
||||||
|
if not obj.player:
|
||||||
|
continue
|
||||||
|
obj = obj.player
|
||||||
|
if not obj.is_connected:
|
||||||
continue
|
continue
|
||||||
obj = obj.player
|
except ObjectDoesNotExist:
|
||||||
if not obj.is_connected:
|
# a subscribed object has already been deleted. Mark that we need a recache and ignore it
|
||||||
|
recache_needed = True
|
||||||
continue
|
continue
|
||||||
subs.append(obj)
|
subs.append(obj)
|
||||||
|
if recache_needed:
|
||||||
|
self._recache()
|
||||||
return subs
|
return subs
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue