From a9a70c91b1fd5c429dd4da3c8636979c02f47f64 Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 23 May 2013 21:38:01 +0200 Subject: [PATCH] Fixed a bug with the who command. --- src/commands/default/player.py | 5 +++-- src/objects/manager.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/commands/default/player.py b/src/commands/default/player.py index 7f16e200e9..346c9d1a94 100644 --- a/src/commands/default/player.py +++ b/src/commands/default/player.py @@ -378,10 +378,11 @@ class CmdWho(MuxPlayerCommand): plr_pobject = session.get_puppet() plr_pobject = plr_pobject or session.get_player() table.add_row([utils.crop(plr_pobject.name, width=25), - utils.time.format(delta_conn, 0), + utils.time_format(delta_conn, 0), utils.time_format(delta_cmd, 1)]) - string = "{wPlayers:{n\n%s\n%s unique accounts logged in." % (table, nplayers==1 and "One player" or nplayers) + isone = nplayers == 1 + string = "{wPlayers:{n\n%s\n%s unique account%s logged in." % (table, "One" if isone else nplayers, "" if isone else "s") self.msg(string) diff --git a/src/objects/manager.py b/src/objects/manager.py index 4e71f3d887..41866a3d6b 100644 --- a/src/objects/manager.py +++ b/src/objects/manager.py @@ -134,6 +134,11 @@ class ObjectManager(TypedObjectManager): """ cand_restriction = candidates and Q(pk__in=[_GA(obj, "id") for obj in make_iter(candidates) if obj]) or Q() type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q() + + ## This doesn't work if attribute_value is an object. Workaround below + #q = self.filter(cand_restriction & type_restriction & Q(objattribute__db_key=attribute_name) & Q(objattribute__db_value=attribute_value)) + #return list(q) + if isinstance(attribute_value, (basestring, int, float, bool, long)): return self.filter(cand_restriction & type_restriction & Q(objattribute__db_key=attribute_name, objattribute__db_value=attribute_value)) else: