Fixed an issue with Object manager's is_dbref. Paging should be a lot more sound now too.

This commit is contained in:
Greg Taylor 2009-01-15 05:11:55 +00:00
parent 9246ce684f
commit 914628d385
4 changed files with 17 additions and 14 deletions

View file

@ -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):
"""

View file

@ -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