Added global_dbref argument to caller.search, for allowing e.g. the examine command to view globally by dbref yet local-only if supplying a name. Resolves Issue 327.

This commit is contained in:
Griatch 2012-12-08 14:09:42 +01:00
parent 7ee40bc3c7
commit c0302f7cff
3 changed files with 9 additions and 3 deletions

View file

@ -1750,7 +1750,7 @@ class CmdExamine(ObjManipCommand):
self.player_mode = "player" in self.switches or obj_name.startswith('*')
obj = caller.search(obj_name, player=self.player_mode)
obj = caller.search(obj_name, player=self.player_mode, global_dbref=True)
if not obj:
continue

View file

@ -508,6 +508,7 @@ class ObjectDB(TypedObject):
def search(self, ostring,
global_search=False,
global_dbref=False,
attribute_name=None,
use_nicks=False, location=None,
player=False,
@ -521,6 +522,7 @@ class ObjectDB(TypedObject):
start of ostring.
global_search: Search all objects, not just the current
location/inventory. This is overruled if location keyword is given.
global_dbref: Search globally -only- if a valid #dbref is given, otherwise local.
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, and caller.contents.
@ -558,6 +560,7 @@ class ObjectDB(TypedObject):
if ostring in (_ME, _SELF, '*' + _ME, '*' + _SELF):
return self
if use_nicks:
nick = None
nicktype = "object"
@ -574,7 +577,7 @@ class ObjectDB(TypedObject):
break
candidates=None
if global_search:
if global_search or (global_dbref and ostring.startswith("#")):
# only allow exact matching if searching the entire database
exact = True
elif location:

View file

@ -92,7 +92,8 @@ class Object(TypeClass):
* Helper methods (see src.objects.objects.py for full headers)
search(ostring, global_search=False, attribute_name=None, use_nicks=False, location=None, ignore_errors=False, player=False)
search(ostring, global_search=False, global_dbref=False, attribute_name=None,
use_nicks=False, location=None, ignore_errors=False, player=False)
execute_cmd(raw_string)
msg(message, from_obj=None, data=None)
msg_contents(message, exclude=None, from_obj=None, data=None)
@ -150,6 +151,7 @@ class Object(TypeClass):
def search(self, ostring,
global_search=False,
global_dbref=False,
attribute_name=None,
use_nicks=False,
location=None,
@ -195,6 +197,7 @@ class Object(TypeClass):
"""
return self.dbobj.search(ostring,
global_search=global_search,
global_dbref=global_dbref,
attribute_name=attribute_name,
use_nicks=use_nicks,
location=location,