'Search as an object globally or in a list of candidates and
return results. The result is always an Object. Always returns
a list.
Args:
searchdata (str or Object): The entity to match for. This is
usually a key string but may also be an object itself.
By default (if no `attribute_name` is set), this will
search `object.key` and `object.aliases` in order.
Can also be on the form #dbref, which will (if
`exact=True`) be matched against primary key.
attribute_name (str): Use this named Attribute to
match searchdata against, instead of the defaults. If
this is the name of a database field (with or without
the `db_` prefix), that will be matched too.
typeclass (str or TypeClass): restrict matches to objects
having this typeclass. This will help speed up global
searches.
candidates (list): If supplied, search will
only be performed among the candidates in this list. A
common list of candidates is the contents of the
current location searched.
exact (bool): Match names/aliases exactly or partially.
Partial matching matches the beginning of words in the
names/aliases, using a matching routine to separate
multiple matches in names with multiple components (so
"bi sw" will match "Big sword"). Since this is more
expensive than exact matching, it is recommended to be
used together with the `candidates` keyword to limit the
number of possibilities. This value has no meaning if
searching for attributes/properties.
use_dbref (bool): If False, bypass direct lookup of a string
on the form #dbref and treat it like any string.
Returns:
matches (list): Matching objects'

@returns_typeclass_list
def search_object(self, searchdata, attribute_name=None, typeclass=None, candidates=None, exact=True, use_dbref=True):

    def _searcher(searchdata, candidates, typeclass, exact=False):
        '\n                                                Helper    method    for    searching    objects.    `typeclass`    is    only    used\n                                                for    global    searching    (no    candidates)\n                                                '
        if attribute_name:
            matches = self.get_objs_with_db_property_value(attribute_name, searchdata, candidates=candidates, typeclasses=typeclass)
            if matches:
                return matches
            return self.get_objs_with_attr_value(attribute_name, searchdata, candidates=candidates, typeclasses=typeclass)
        else:
            return self.get_objs_with_key_or_alias(searchdata, exact=exact, candidates=candidates, typeclasses=typeclass)
    if ((not searchdata) and (searchdata != 0)):
        return []
    if typeclass:
        typeclasses = make_iter(typeclass)
        for (i, typeclass) in enumerate(make_iter(typeclasses)):
            if callable(typeclass):
                typeclasses[i] = (u'%s.%s' % (typeclass.__module__, typeclass.__name__))
            else:
                typeclasses[i] = (u'%s' % typeclass)
        typeclass = typeclasses
    if (candidates is not None):
        if (not candidates):
            return []
        candidates = [cand for cand in make_iter(candidates) if cand]
        if typeclass:
            candidates = [cand for cand in candidates if (_GA(cand, 'db_typeclass_path') in typeclass)]
    dbref = ((not attribute_name) and exact and use_dbref and self.dbref(searchdata))
    if dbref:
        dbref_match = self.dbref_search(dbref)
        if dbref_match:
            if ((not candidates) or (dbref_match in candidates)):
                return [dbref_match]
            else:
                return []
    match_number = None
    matches = _searcher(searchdata, candidates, typeclass, exact=True)
    if (not matches):
        match = _MULTIMATCH_REGEX.match(searchdata)
        match_number = None
        if match:
            (match_number, searchdata) = (match.group('number'), match.group('name'))
            match_number = (int(match_number) - 1)
            match_number = (match_number if (match_number >= 0) else None)
        if ((match_number is not None) or (not exact)):
            matches = _searcher(searchdata, candidates, typeclass, exact=exact)
    if ((len(matches) > 1) and (match_number is not None)):
        try:
            matches = [matches[match_number]]
        except IndexError:
            pass
    return matches
