diff -r 2c3711d4570b -r 091ac3ba5d51 web/views/magicsearch.py --- a/web/views/magicsearch.py Wed Apr 22 18:42:58 2009 +0200 +++ b/web/views/magicsearch.py Wed Apr 22 18:44:30 2009 +0200 @@ -41,7 +41,7 @@ :param translations: the reverted l10n dict :type schema: `cubicweb.schema.Schema` - :param schema: the application's schema + :param schema: the application's schema """ # var_types is used as a map : var_name / var_type vartypes = {} @@ -107,7 +107,7 @@ if rtype is None: continue relation.r_type = rtype - + QUOTED_SRE = re.compile(r'(.*?)(["\'])(.+?)\2') @@ -145,7 +145,7 @@ return req.execute(*args) finally: # rollback necessary to avoid leaving the connection in a bad state - req.cnx.rollback() + req.cnx.rollback() def preprocess_query(self, uquery, req): raise NotImplementedError() @@ -161,10 +161,10 @@ priority = 0 def preprocess_query(self, uquery, req): return uquery, - + class QueryTranslator(BaseQueryProcessor): - """ parses through rql and translates into schema language entity names + """ parses through rql and translates into schema language entity names and attributes """ priority = 2 @@ -185,7 +185,7 @@ preprocessing query in shortcut form to their RQL form """ priority = 4 - + def preprocess_query(self, uquery, req): """try to get rql from an unicode query string""" args = None @@ -193,7 +193,7 @@ try: # Process as if there was a quoted part args = self._quoted_words_query(uquery) - ## No quoted part + ## No quoted part except BadRQLQuery: words = uquery.split() if len(words) == 1: @@ -205,7 +205,7 @@ else: args = self._multiple_words_query(words) return args - + def _get_entity_type(self, word): """check if the given word is matching an entity type, return it if it's the case or raise BadRQLQuery if not @@ -214,7 +214,7 @@ try: return trmap(self.config, self.vreg.schema, self.req.lang)[etype] except KeyError: - raise BadRQLQuery('%s is not a valid entity name' % etype) + raise BadRQLQuery('%s is not a valid entity name' % etype) def _get_attribute_name(self, word, eschema): """check if the given word is matching an attribute of the given entity type, @@ -261,7 +261,7 @@ if var is None: var = etype[0] return '%s %s %s%%(text)s' % (var, searchattr, searchop) - + def _two_words_query(self, word1, word2): """Specific process for two words query (case (2) of preprocess_rql) """ @@ -272,7 +272,7 @@ # else, suppose it's a shortcut like : Person Smith rql = '%s %s WHERE %s' % (etype, etype[0], self._complete_rql(word2, etype)) return rql, {'text': word2} - + def _three_words_query(self, word1, word2, word3): """Specific process for three words query (case (3) of preprocess_rql) """ @@ -336,13 +336,13 @@ return self._three_words_query(word1, word2, quoted_part) # return ori_rql raise BadRQLQuery("unable to handle request %r" % ori_rql) - + - + class FullTextTranslator(BaseQueryProcessor): priority = 10 name = 'text' - + def preprocess_query(self, uquery, req): """suppose it's a plain text query""" return 'Any X WHERE X has_text %(text)s', {'text': uquery}