def search(self): self.sphinx.SetConnectTimeout(10.0) # create a quadindex if the bbox is defined if self.bbox is not None and self.typeInfo not in ('layers', 'featuresearch'): self._get_quad_index() if self.typeInfo == 'layers': # search all layers self.searchText = format_search_text( self.request.params.get('searchText') ) self._layer_search() elif self.typeInfo == 'featuresearch': # search all features using searchText self.searchText = format_search_text( self.request.params.get('searchText') ) self._feature_search() elif self.typeInfo in ('locations', 'locations_preview'): self.searchText = format_locations_search_text( self.request.params.get('searchText', '') ) # swiss search self._swiss_search() # translate some gazetteer categories from swissnames3 tagged with <i>...</i> in the label attribute of the response return self.results
def search(self): self.sphinx.SetConnectTimeout(10.0) # create a quadindex if the bbox is defined if self.bbox is not None and self.typeInfo not in ('layers', 'featuresearch'): self._get_quad_index() if self.typeInfo == 'layers': # search all layers self.searchText = format_search_text( self.request.params.get('searchText') ) self._layer_search() elif self.typeInfo == 'featuresearch': # search all features using searchText self.searchText = format_search_text( self.request.params.get('searchText') ) self._feature_search() elif self.typeInfo == 'locations' or self.typeInfo == 'locations_preview': self.searchText = format_search_text( self.request.params.get('searchText', '') ) # swiss search self._swiss_search() # translate some gazetteer categories from swissnames3 tagged with <i>...</i> in the label attribute of the response for key, value in enumerate(self.results['results']): translation = re.search(r'.*(<i>[\s\S]*?<\/i>).*', value['attrs']['label']) or False if translation: self.results['results'][key]['attrs']['label'] = value['attrs']['label'].replace( translation.group(1), '<i>%s</i>' % str(self.request.translate(translation.group(1)).encode('utf-8'))) return self.results
def search(self): self.sphinx.SetConnectTimeout(3.5) # create a quadindex if the bbox is defined if self.bbox is not None and self.typeInfo != 'layers': self._get_quad_index() if self.typeInfo == 'layers': # search all layers self.searchText = format_search_text( self.request.params.get('searchText') ) self._layer_search() if self.typeInfo in ('features', 'featureidentify'): # search all features within bounding box self._feature_bbox_search() if self.typeInfo == 'featuresearch': # search all features using searchText self.searchText = format_search_text( self.request.params.get('searchText') ) self._feature_search() if self.typeInfo == 'locations': # search all features with text and bounding box self.searchText = format_search_text( self.request.params.get('searchText') ) self._feature_search() # swiss search self._swiss_search(self.LIMIT) return self.results
def search(self): self.sphinx.SetConnectTimeout(10.0) # create a quadindex if the bbox is defined if self.bbox is not None and self.typeInfo not in ('layers', 'featuresearch'): self._get_quad_index() if self.typeInfo == 'layers': # search all layers self.searchText = format_search_text( self.request.params.get('searchText') ) self._layer_search() elif self.typeInfo in ('features', 'featureidentify'): # search all features within bounding box self._feature_bbox_search() elif self.typeInfo == 'featuresearch': # search all features using searchText self.searchText = format_search_text( self.request.params.get('searchText') ) self._feature_search() elif self.typeInfo == 'locations': self.searchText = format_search_text( self.request.params.get('searchText', '') ) # swiss search self._swiss_search() return self.results
def test_format_search_text(self): testinput_str = 'Hallo!' result = format_search_text(testinput_str) self.assertEqual(result, 'Hallo\\!') testinput_str2 = u'über' result2 = format_search_text(testinput_str2) self.assertEqual(result2, 'ueber')
def search(self): self.sphinx.SetConnectTimeout(10.0) # create a quadindex if the bbox is defined if self.bbox is not None and self.typeInfo not in ("layers", "featuresearch"): self._get_quad_index() if self.typeInfo == "layers": # search all layers self.searchText = format_search_text(self.request.params.get("searchText")) self._layer_search() elif self.typeInfo == "featuresearch": # search all features using searchText self.searchText = format_search_text(self.request.params.get("searchText")) self._feature_search() elif self.typeInfo == "locations" or self.typeInfo == "locations_preview": self.searchText = format_search_text(self.request.params.get("searchText", "")) # swiss search self._swiss_search() return self.results
def search(self): self.sphinx.SetConnectTimeout(10.0) # create a quadindex if the bbox is defined if self.bbox is not None and self.typeInfo not in ('layers', 'featuresearch'): self._get_quad_index() if self.typeInfo == 'layers': # search all layers self.searchText = format_search_text( self.request.params.get('searchText')) self._layer_search() elif self.typeInfo == 'featuresearch': # search all features using searchText self.searchText = format_search_text( self.request.params.get('searchText')) self._feature_search() elif self.typeInfo in ('locations'): self.searchText = format_locations_search_text( self.request.params.get('searchText', '')) # swiss search self._swiss_search() # translate some gazetteer categories from swissnames3 tagged with <i>...</i> in the label attribute of the response return self.results