Resolves issue 133. Added the location keyword to the ObjectDB.search() method for easier customizable object searches.

This commit is contained in:
Griatch 2011-02-27 22:55:42 +00:00
parent 2bdaf034c8
commit 9dcfea5971
3 changed files with 20 additions and 15 deletions

View file

@ -167,7 +167,7 @@ class ObjectManager(TypedObjectManager):
@returns_typeclass_list
def object_search(self, character, ostring,
global_search=False,
attribute_name=None):
attribute_name=None, location=None):
"""
Search as an object and return results.
@ -177,13 +177,15 @@ class ObjectManager(TypedObjectManager):
global_search: Search all objects, not just the current location/inventory
attribute_name: (string) Which attribute to search in each object.
If None, the default 'key' attribute is used.
location: If None, character.location will be used.
"""
#ostring = str(ostring).strip()
if not ostring or not character:
return None
location = character.location
if not location:
location = character.location
# Easiest case - dbref matching (always exact)
dbref = self.dbref(ostring)

View file

@ -434,7 +434,7 @@ class ObjectDB(TypedObject):
def search(self, ostring,
global_search=False,
attribute_name=None,
use_nicks=False,
use_nicks=False, location=None,
ignore_errors=False):
"""
Perform a standard object search in the database, handling
@ -451,6 +451,7 @@ class ObjectDB(TypedObject):
attribute_name: (string) Which attribute to match
(if None, uses default 'name')
use_nicks : Use nickname replace (off by default)
location : If None, use caller's current location
ignore_errors : Don't display any error messages even
if there are none/multiple matches -
just return the result as a list.
@ -473,7 +474,8 @@ class ObjectDB(TypedObject):
results = ObjectDB.objects.object_search(self, ostring,
global_search=global_search,
attribute_name=attribute_name)
attribute_name=attribute_name,
location=location)
if ignore_errors:
return results