diff --git a/src/commands/default/general.py b/src/commands/default/general.py index f87ef24d79..e366eb567c 100644 --- a/src/commands/default/general.py +++ b/src/commands/default/general.py @@ -677,7 +677,7 @@ class CmdIC(MuxCommandOOC): return if not new_character: # search for a matching character - new_character = search.objects(self.args, caller, global_search=True, single_result=True) + new_character = search.objects(self.args, caller) if new_character: new_character = new_character[0] else: diff --git a/src/commands/default/system.py b/src/commands/default/system.py index cf5ce48ce7..41b9594e64 100644 --- a/src/commands/default/system.py +++ b/src/commands/default/system.py @@ -262,7 +262,7 @@ class CmdScripts(MuxCommand): scripts = ScriptDB.objects.get_all_scripts(key=args) if not scripts: # try to find an object instead. - objects = ObjectDB.objects.object_search(args, caller=caller, global_search=True) + objects = ObjectDB.objects.object_search(args, caller=caller) if objects: scripts = [] for obj in objects: diff --git a/src/utils/search.py b/src/utils/search.py index db75d075ac..eb0f305a64 100644 --- a/src/utils/search.py +++ b/src/utils/search.py @@ -1,9 +1,9 @@ """ This is a convenient container gathering all the main -search methods for the various database tables. +search methods for the various database tables. -It is intended to be used e.g. as +It is intended to be used e.g. as > from src.utils import search > match = search.objects(...) @@ -11,12 +11,12 @@ It is intended to be used e.g. as Note that this is not intended to be a complete listing of all search methods! You need to refer to the respective manager to get all possible search methods. To get to the managers from your code, import -the database model and call its 'objects' property. +the database model and call its 'objects' property. Also remember that all commands in this file return lists (also if there is only one match) unless noted otherwise. -Example: To reach the search method 'get_object_with_user' +Example: To reach the search method 'get_object_with_user' in src/objects/managers.py: > from src.objects.models import ObjectDB @@ -43,45 +43,45 @@ HelpEntry = ContentType.objects.get(app_label="help", model="helpentry").model_c # # Search objects as a character -# +# # NOTE: A more powerful wrapper of this method # is reachable from within each command class -# by using self.caller.search()! +# by using self.caller.search()! # # def object_search(self, ostring, caller=None, -# global_search=False, +# candidates=None, # attribute_name=None): # """ # Search as an object and return results. -# +# # ostring: (string) The string to compare names against. -# Can be a dbref. If name is appended by *, a player is searched for. +# Can be a dbref. If name is appended by *, a player is searched for. # caller: (Object) The object performing the search. -# global_search: Search all objects, not just the current location/inventory +# candidates (list of Objects): restrict search only to those objects # attribute_name: (string) Which attribute to search in each object. -# If None, the default 'name' attribute is used. +# If None, the default 'name' attribute is used. # """ search_object = ObjectDB.objects.object_search search_objects = search_object objects = search_objects # -# Search for players +# Search for players # # NOTE: Most usually you would do such searches from -# from inseide command definitions using -# self.caller.search() by appending an '*' to the +# from inseide command definitions using +# self.caller.search() by appending an '*' to the # beginning of the search criterion. # # def player_search(self, ostring): # """ -# Searches for a particular player by name or +# Searches for a particular player by name or # database id. # # ostring = a string or database id. # """ -search_player = PlayerDB.objects.player_search +search_player = PlayerDB.objects.player_search search_players = search_player players = search_players @@ -91,11 +91,11 @@ players = search_players # def script_search(self, ostring, obj=None, only_timed=False): # """ # Search for a particular script. -# +# # ostring - search criterion - a script ID or key # obj - limit search to scripts defined on this object # only_timed - limit search only to scripts that run -# on a timer. +# on a timer. # """ search_script = ScriptDB.objects.script_search @@ -105,18 +105,18 @@ scripts = search_scripts # Searching for communication messages # # -# def message_search(self, sender=None, receiver=None, channel=None, freetext=None): +# def message_search(self, sender=None, receiver=None, channel=None, freetext=None): # """ -# Search the message database for particular messages. At least one -# of the arguments must be given to do a search. +# Search the message database for particular messages. At least one +# of the arguments must be given to do a search. # # sender - get messages sent by a particular player # receiver - get messages received by a certain player -# channel - get messages sent to a particular channel -# freetext - Search for a text string in a message. +# channel - get messages sent to a particular channel +# freetext - Search for a text string in a message. # NOTE: This can potentially be slow, so make sure to supply -# one of the other arguments to limit the search. -# """ +# one of the other arguments to limit the search. +# """ search_message = Msg.objects.message_search search_messages = search_message @@ -137,7 +137,7 @@ search_channels = search_channel channels = search_channels # -# Find help entry objects. +# Find help entry objects. # # def search_help(self, ostring, help_category=None): # """ @@ -147,6 +147,6 @@ channels = search_channels # category - limit the search to a particular help topic # """ -search_help_entry = HelpEntry.objects.search_help +search_help_entry = HelpEntry.objects.search_help search_help_entries = search_help_entry help_entries = search_help_entries