Fixed erroneous global_search keyword in a few places in the code due to the API having changed. Resolves issue 276.

This commit is contained in:
Griatch 2012-10-14 12:06:42 +02:00
parent 8b582c9d3f
commit 97973dd5f9
3 changed files with 29 additions and 29 deletions

View file

@ -677,7 +677,7 @@ class CmdIC(MuxCommandOOC):
return return
if not new_character: if not new_character:
# search for a matching 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: if new_character:
new_character = new_character[0] new_character = new_character[0]
else: else:

View file

@ -262,7 +262,7 @@ class CmdScripts(MuxCommand):
scripts = ScriptDB.objects.get_all_scripts(key=args) scripts = ScriptDB.objects.get_all_scripts(key=args)
if not scripts: if not scripts:
# try to find an object instead. # 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: if objects:
scripts = [] scripts = []
for obj in objects: for obj in objects:

View file

@ -1,9 +1,9 @@
""" """
This is a convenient container gathering all the main 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 > from src.utils import search
> match = search.objects(...) > 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 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 methods! You need to refer to the respective manager to get all
possible search methods. To get to the managers from your code, import 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 Also remember that all commands in this file return lists (also if
there is only one match) unless noted otherwise. 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: in src/objects/managers.py:
> from src.objects.models import ObjectDB > 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 # Search objects as a character
# #
# NOTE: A more powerful wrapper of this method # NOTE: A more powerful wrapper of this method
# is reachable from within each command class # is reachable from within each command class
# by using self.caller.search()! # by using self.caller.search()!
# #
# def object_search(self, ostring, caller=None, # def object_search(self, ostring, caller=None,
# global_search=False, # candidates=None,
# attribute_name=None): # attribute_name=None):
# """ # """
# Search as an object and return results. # Search as an object and return results.
# #
# ostring: (string) The string to compare names against. # 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. # 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. # 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_object = ObjectDB.objects.object_search
search_objects = search_object search_objects = search_object
objects = search_objects objects = search_objects
# #
# Search for players # Search for players
# #
# NOTE: Most usually you would do such searches from # NOTE: Most usually you would do such searches from
# from inseide command definitions using # from inseide command definitions using
# self.caller.search() by appending an '*' to the # self.caller.search() by appending an '*' to the
# beginning of the search criterion. # beginning of the search criterion.
# #
# def player_search(self, ostring): # def player_search(self, ostring):
# """ # """
# Searches for a particular player by name or # Searches for a particular player by name or
# database id. # database id.
# #
# ostring = a string 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 search_players = search_player
players = search_players players = search_players
@ -91,11 +91,11 @@ players = search_players
# def script_search(self, ostring, obj=None, only_timed=False): # def script_search(self, ostring, obj=None, only_timed=False):
# """ # """
# Search for a particular script. # Search for a particular script.
# #
# ostring - search criterion - a script ID or key # ostring - search criterion - a script ID or key
# obj - limit search to scripts defined on this object # obj - limit search to scripts defined on this object
# only_timed - limit search only to scripts that run # only_timed - limit search only to scripts that run
# on a timer. # on a timer.
# """ # """
search_script = ScriptDB.objects.script_search search_script = ScriptDB.objects.script_search
@ -105,18 +105,18 @@ scripts = search_scripts
# Searching for communication messages # 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 # Search the message database for particular messages. At least one
# of the arguments must be given to do a search. # of the arguments must be given to do a search.
# #
# sender - get messages sent by a particular player # sender - get messages sent by a particular player
# receiver - get messages received by a certain player # receiver - get messages received by a certain player
# channel - get messages sent to a particular channel # channel - get messages sent to a particular channel
# freetext - Search for a text string in a message. # freetext - Search for a text string in a message.
# NOTE: This can potentially be slow, so make sure to supply # 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_message = Msg.objects.message_search
search_messages = search_message search_messages = search_message
@ -137,7 +137,7 @@ search_channels = search_channel
channels = search_channels channels = search_channels
# #
# Find help entry objects. # Find help entry objects.
# #
# def search_help(self, ostring, help_category=None): # def search_help(self, ostring, help_category=None):
# """ # """
@ -147,6 +147,6 @@ channels = search_channels
# category - limit the search to a particular help topic # 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 search_help_entries = search_help_entry
help_entries = search_help_entries help_entries = search_help_entries