equal
deleted
inserted
replaced
170 and attributes |
170 and attributes |
171 """ |
171 """ |
172 priority = 2 |
172 priority = 2 |
173 def preprocess_query(self, uquery): |
173 def preprocess_query(self, uquery): |
174 rqlst = parse(uquery, print_errors=False) |
174 rqlst = parse(uquery, print_errors=False) |
175 schema = self._cw.schema |
175 schema = self._cw.vreg.schema |
176 # rql syntax tree will be modified in place if necessary |
176 # rql syntax tree will be modified in place if necessary |
177 translate_rql_tree(rqlst, trmap(self._cw.config, schema, self._cw.lang), |
177 translate_rql_tree(rqlst, trmap(self._cw.config, schema, self._cw.lang), |
178 schema) |
178 schema) |
179 return rqlst.as_string(), |
179 return rqlst.as_string(), |
180 |
180 |
248 |
248 |
249 def _complete_rql(self, searchstr, etype, rtype=None, var=None, searchattr=None): |
249 def _complete_rql(self, searchstr, etype, rtype=None, var=None, searchattr=None): |
250 searchop = '' |
250 searchop = '' |
251 if '%' in searchstr: |
251 if '%' in searchstr: |
252 if rtype: |
252 if rtype: |
253 possible_etypes = self._cw.schema.rschema(rtype).objects(etype) |
253 possible_etypes = self._cw.vreg.schema.rschema(rtype).objects(etype) |
254 else: |
254 else: |
255 possible_etypes = [self._cw.schema.eschema(etype)] |
255 possible_etypes = [self._cw.vreg.schema.eschema(etype)] |
256 if searchattr or len(possible_etypes) == 1: |
256 if searchattr or len(possible_etypes) == 1: |
257 searchattr = searchattr or possible_etypes[0].main_attribute() |
257 searchattr = searchattr or possible_etypes[0].main_attribute() |
258 searchop = 'LIKE ' |
258 searchop = 'LIKE ' |
259 searchattr = searchattr or 'has_text' |
259 searchattr = searchattr or 'has_text' |
260 if var is None: |
260 if var is None: |
274 |
274 |
275 def _three_words_query(self, word1, word2, word3): |
275 def _three_words_query(self, word1, word2, word3): |
276 """Specific process for three words query (case (3) of preprocess_rql) |
276 """Specific process for three words query (case (3) of preprocess_rql) |
277 """ |
277 """ |
278 etype = self._get_entity_type(word1) |
278 etype = self._get_entity_type(word1) |
279 eschema = self._cw.schema.eschema(etype) |
279 eschema = self._cw.vreg.schema.eschema(etype) |
280 rtype = self._get_attribute_name(word2, eschema) |
280 rtype = self._get_attribute_name(word2, eschema) |
281 # expand shortcut if rtype is a non final relation |
281 # expand shortcut if rtype is a non final relation |
282 if not self._cw.schema.rschema(rtype).final: |
282 if not self._cw.vreg.schema.rschema(rtype).final: |
283 return self._expand_shortcut(etype, rtype, word3) |
283 return self._expand_shortcut(etype, rtype, word3) |
284 if '%' in word3: |
284 if '%' in word3: |
285 searchop = 'LIKE ' |
285 searchop = 'LIKE ' |
286 else: |
286 else: |
287 searchop = '' |
287 searchop = '' |