From 914628d385ec2b1688057a44f671165f15f052ec Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Thu, 15 Jan 2009 05:11:55 +0000 Subject: [PATCH] Fixed an issue with Object manager's is_dbref. Paging should be a lot more sound now too. --- src/cmdtable.py | 3 +-- src/commands/paging.py | 12 ++++++------ src/objects/managers/object.py | 2 +- src/objects/util/object.py | 14 +++++++++----- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/cmdtable.py b/src/cmdtable.py index 7bc2278242..4cab99c7b2 100644 --- a/src/cmdtable.py +++ b/src/cmdtable.py @@ -91,8 +91,7 @@ GLOBAL_CMD_TABLE.add_command("@find", commands.objmanip.cmd_find, priv_tuple=("genperms.builder")), GLOBAL_CMD_TABLE.add_command("@link", commands.objmanip.cmd_link, priv_tuple=("genperms.builder")), -GLOBAL_CMD_TABLE.add_command("@list", commands.info.cmd_list, - priv_tuple=("genperms.process_control")), +GLOBAL_CMD_TABLE.add_command("@list", commands.info.cmd_list), GLOBAL_CMD_TABLE.add_command("@name", commands.objmanip.cmd_name), GLOBAL_CMD_TABLE.add_command("@nextfree", commands.objmanip.cmd_nextfree, priv_tuple=("genperms.builder")), diff --git a/src/commands/paging.py b/src/commands/paging.py index d4652f5679..0ecad3e9ff 100644 --- a/src/commands/paging.py +++ b/src/commands/paging.py @@ -34,12 +34,9 @@ def cmd_page(command): """ session = command.session pobject = session.get_pobject() - args = command.command_argument.split() - targets = [] - # Get the last paged person(s) last_paged_objects = get_last_paged_objects(pobject) - + # If they don't give a target, or any data to send to the target # then tell them who they last paged if they paged someone, if not # tell them they haven't paged anyone. @@ -50,6 +47,9 @@ def cmd_page(command): return session.msg("You have not paged anyone.") return + + args = command.command_argument.split() + targets = [] # Build a list of targets # If there are no targets, then set the targets to the last person they @@ -66,7 +66,6 @@ def cmd_page(command): limit_types=[defines_global.OTYPE_PLAYER]) if matched_object: targets.append(matched_object[0]) - print "MATCH:", matched_object[0] else: # search returned None session.msg("Player '%s' can not be found." % ( @@ -77,7 +76,8 @@ def cmd_page(command): if command.arg_has_target(): message = command.get_arg_target_value() else: - message = command.command_argument + session.msg("Page them what?") + return sender_name = pobject.get_name(show_dbref=False) # Build our messages diff --git a/src/objects/managers/object.py b/src/objects/managers/object.py index e2fceed334..f570d9c4a3 100644 --- a/src/objects/managers/object.py +++ b/src/objects/managers/object.py @@ -183,7 +183,7 @@ class ObjectManager(models.Manager): """ Is the input a well-formed dbref number? """ - util_object.is_dbref(dbstring) + return util_object.is_dbref(dbstring) def dbref_search(self, dbref_string, limit_types=False): """ diff --git a/src/objects/util/object.py b/src/objects/util/object.py index 1e8cb9d242..e9500f6421 100644 --- a/src/objects/util/object.py +++ b/src/objects/util/object.py @@ -6,16 +6,20 @@ def is_dbref(dbstring): """ Is the input a well-formed dbref number? """ + # Strip the leading # sign if it's there. + if dbstring.startswith("#"): + dbstring = dbstring[1:] + try: - number = int(dbstring[1:]) + # If this fails, it's probably not valid. + number = int(dbstring) except ValueError: return False except TypeError: return False - - if not dbstring.startswith("#"): - return False - elif number < 1: + + # Numbers less than 1 are not valid dbrefs. + if number < 1: return False else: return True