From 77a0b47859769db79c7035405cdf04cad30c4775 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 14 May 2013 13:55:03 +0200 Subject: [PATCH] Fixed some issues with the _superuser_character bypass as well as the is_superuser property on objects. Also fixed a bug with @examine that caused it to display object Attribute instead of Player Attributes when called from the ooc state. --- src/commands/default/building.py | 11 ++++++++--- src/locks/lockhandler.py | 5 +---- src/objects/models.py | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/commands/default/building.py b/src/commands/default/building.py index 7a62aa917..2cbbeda62 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -1547,6 +1547,7 @@ class CmdExamine(ObjManipCommand): else: if self.player_mode: db_attr = [(attr.key, attr.value) for attr in PlayerAttribute.objects.filter(db_obj=obj)] + print "player mode:", db_attr else: db_attr = [(attr.key, attr.value) for attr in ObjAttribute.objects.filter(db_obj=obj)] try: @@ -1683,10 +1684,14 @@ class CmdExamine(ObjManipCommand): obj_name = objdef['name'] obj_attrs = objdef['attrs'] - - self.player_mode = "player" in self.switches or obj_name.startswith('*') + self.player_mode = utils.inherits_from(caller, "src.players.player.Player") or \ + "player" in self.switches or obj_name.startswith('*') if self.player_mode: - obj = caller.search_player(obj_name.lstrip('*')) + try: + obj = caller.search_player(obj_name.lstrip('*')) + except AttributeError: + # this means we are calling examine from a player object + obj = caller.search(obj_name.lstrip('*')) else: obj = caller.search(obj_name) if not obj: diff --git a/src/locks/lockhandler.py b/src/locks/lockhandler.py index d11eadc6d..c55fed1a6 100644 --- a/src/locks/lockhandler.py +++ b/src/locks/lockhandler.py @@ -260,10 +260,7 @@ class LockHandler(object): before the login process has yet been fully finalized) """ #print "_superuser_character:", hasattr(obj, "get_attribute") and obj.get_attribute("_superuser_character") - self.lock_bypass = (hasattr(obj, "is_superuser") and obj.is_superuser - or ((hasattr(obj, "get_attribute") and obj.get_attribute("_superuser_character")) - and ((hasattr(obj, "player") and hasattr(obj.player, "is_superuser") and obj.player.is_superuser) - or (hasattr(obj, "get_player") and (not obj.get_player() or obj.get_player().is_superuser))))) + self.lock_bypass = hasattr(obj, "is_superuser") and obj.is_superuser def add(self, lockstring, log_obj=None): """ diff --git a/src/objects/models.py b/src/objects/models.py index 47c898858..fa22afbf1 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -496,7 +496,8 @@ class ObjectDB(TypedObject): #@property def __is_superuser_get(self): "Check if user has a player, and if so, if it is a superuser." - return any(_GA(self, "sessions")) and _GA(_GA(self, "db_player"), "is_superuser") + return (_GA(self, "db_player") and _GA(_GA(self, "db_player"), "is_superuser") + and _GA(self, "get_attribute")("_superuser_character")) is_superuser = property(__is_superuser_get) # contents