def hook_alias(self, alias, model_obj=None):
        '''
        Returns the alias function, if it exists and if it can be applied to this model.
        '''
        try:
            search_alias = self._alias_hooks[alias]
        except KeyError:
            raise AttributeError('Could not find search alias named {}. Is this alias defined in BUNGIESEARCH["ALIASES"]?'.format(alias))
        else:
            if search_alias._applicable_models and \
                ((model_obj and model_obj not in search_alias._applicable_models) or \
                 not any([app_model_obj.__name__ in self._doc_type for app_model_obj in search_alias._applicable_models])):
                    raise ValueError('Search alias {} is not applicable to model/doc_types {}.'.format(alias, model_obj if model_obj else self._doc_type))
            return search_alias.prepare(self, model_obj).alias_for
def hook_alias ( self , alias , model_obj = None ) : try : search_alias = self . _alias_hooks [ alias ] except KeyError : raise AttributeError ( 'Could not find search alias named {}. Is this alias defined in BUNGIESEARCH["ALIASES"]?' . format ( alias ) ) else : if search_alias . _applicable_models and ( ( model_obj and model_obj not in search_alias . _applicable_models ) or not any ( [ app_model_obj . __name__ in self . _doc_type for app_model_obj in search_alias . _applicable_models ] ) ) : raise ValueError ( 'Search alias {} is not applicable to model/doc_types {}.' . format ( alias , model_obj if model_obj else self . _doc_type ) ) return search_alias . prepare ( self , model_obj ) . alias_for
Returns the alias function, if it exists and if it can be applied to this model.