Merge. Added updates to some of the fixes, such as making channel connetion updates look for online Players instead of online Sessions (the latter would have created duplicates in a multi-session environment).
This commit is contained in:
commit
878f83aba0
3 changed files with 15 additions and 13 deletions
|
|
@ -11,6 +11,7 @@ _GA = object.__getattribute__
|
|||
_PlayerDB = None
|
||||
_ObjectDB = None
|
||||
_Channel = None
|
||||
_SESSIONS = None
|
||||
_ExternalConnection = None
|
||||
_User = None
|
||||
|
||||
|
|
@ -305,24 +306,21 @@ class ChannelManager(models.Manager):
|
|||
to this channel. If Online is true, it only returns
|
||||
connected players.
|
||||
"""
|
||||
global _SESSIONS
|
||||
if not _SESSIONS:
|
||||
from src.server.sessionhandler import SESSIONS as _SESSIONS
|
||||
|
||||
PlayerChannelConnection = ContentType.objects.get(app_label="comms",
|
||||
model="playerchannelconnection").model_class()
|
||||
ExternalChannelConnection = ContentType.objects.get(app_label="comms",
|
||||
model="externalchannelconnection").model_class()
|
||||
# Importing here to avoid circular imports.
|
||||
from src.server.sessionhandler import SESSIONS
|
||||
players = []
|
||||
if online:
|
||||
session_list = SESSIONS.get_sessions()
|
||||
for session in session_list:
|
||||
if not session.logged_in:
|
||||
continue
|
||||
try:
|
||||
players.append(PlayerChannelConnection.objects.get(db_player=session.get_player(),
|
||||
db_channel=channel))
|
||||
except PlayerChannelConnection.DoesNotExist:
|
||||
pass
|
||||
session_list = _SESSIONS.get_sessions()
|
||||
unique_online_users = set(sess.uid for sess in session_list if sess.logged_in)
|
||||
online_players = (sess.get_player() for sess in session_list if sess.uid in unique_online_users)
|
||||
for player in online_players:
|
||||
players.extend(PlayerChannelConnection.objects.filter(db_player=player, db_channel=channel))
|
||||
else:
|
||||
players.extend(PlayerChannelConnection.objects.get_all_connections(channel))
|
||||
|
||||
|
|
|
|||
|
|
@ -183,6 +183,10 @@ class ObjectManager(TypedObjectManager):
|
|||
return list(self.filter(cand_restriction & type_restriction & Q(**querykwargs)))
|
||||
except exceptions.FieldError:
|
||||
return []
|
||||
except ValueError:
|
||||
from src.utils import logger
|
||||
logger.log_errmsg("The property '%s' does not support search criteria of the type %s." % (property_name, type(property_value)))
|
||||
return []
|
||||
|
||||
@returns_typeclass_list
|
||||
def get_contents(self, location, excludeobj=None):
|
||||
|
|
@ -253,7 +257,8 @@ class ObjectManager(TypedObjectManager):
|
|||
By default (if not attribute_name is set), this will search object.key and object.aliases in order. Can also
|
||||
be on the form #dbref, which will, if exact=True be matched against primary key.
|
||||
attribute_name: (str): Use this named ObjectAttribute to match searchdata against, instead
|
||||
of the defaults.
|
||||
of the defaults. If this is the name of a database field (with or without the db_ prefix), that
|
||||
will be matched too.
|
||||
typeclass (str or TypeClass): restrict matches to objects having this typeclass. This will help
|
||||
speed up global searches.
|
||||
candidates (list obj ObjectDBs): If supplied, search will only be performed among the candidates
|
||||
|
|
|
|||
|
|
@ -126,7 +126,6 @@ GAME_CACHE_TYPE = "local"
|
|||
# memory. So every now and then Evennia checks the size of this cache and resets
|
||||
# it if it's too big. This variable sets the maximum size (in MB).
|
||||
ATTRIBUTE_CACHE_MAXSIZE = 100
|
||||
# OOB (Out-of-band
|
||||
|
||||
######################################################################
|
||||
# Evennia Database config
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue