def search_view(): subject_id = request.form.get('subject_id', '') type = request.form.get('type', 'song') comments = search(subject_id, type) return { 'comments': [comment.to_dict() for comment in comments] }
def search(): if not request.json: abort(400) if 'reg_status' in request.json and type( request.json['reg_status']) is not bool: abort(400) if 'vacc_status' in request.json and type( request.json['vacc_status']) is not bool: abort(400) criteria = {} if 'registration_id' in request.json: registration_id = str(request.json['registration_id']).strip() criteria['registration_id'] = registration_id if 'name' in request.json: name = str(request.json['name']).strip().capitalize() criteria['name'] = name if 'handler_id' in request.json: handler_id = request.json['handler_id'] if not (handler_id is None): str(handler_id).strip() criteria['handler_id'] = handler_id if 'reg_status' in request.json: criteria['reg_status'] = request.json['reg_status'] if 'vacc_status' in request.json: criteria['vacc_status'] = request.json['vacc_status'] dogs = models.search(criteria) return jsonify({'dogs': dogs})
def __main_process__(input_string): # the game model global game, counter, game_limit, game_hints, main_word, bool_index global game_score if len(input_string) == 1: # if user input was a single char indexes = H.search(main_word, input_string) if len(indexes) != 0: H.update(bool_index, indexes) counter += len(indexes) else: # less or more than one words compare differently if input_string == main_word: H.game_done(bool_index) game_score += game_hints game = False elif input_string == "hint()": # using the hints if game_hints > 0: H.hint(bool_index, main_word) game_hints -= 1 game_limit += 1 counter += 1 else: return if counter == word_len: game_score += 1 game = False if game_limit == 0: game = False game_limit += 1 game_limit -= 1
def search(): ''' Displays set search results for a given query. Note: search is difficult on app engine, due to lack of "LIKE" operator in GQL queries. ''' query = request.args.get('q',False) results = models.search(query,10) return render_template('browse.html', searchquery=query, results=results)
def search_group(): form = SearchForm(request.form) if request.method == 'POST': match = models.search(form.search.data, form.value.data) search = form.search.data return render_template('pages/placeholder.search.html', search=search, match=match) return render_template('forms/search_group.html', form=form)
def testdb(): #pic = Pic.query.all()[0] #tag = Tag.query.filter_by(name='pictag').first() #print tag #print pic #pic.remove_tag(tag) #return redirect(url_for('core.printdb')) return '<h1>' + str(search({ 'pics.title': 'test', 'pics.id': 11 })) + '</h1>' '''
def search(self, request): """ Perform a search product. """ products = models.search(request) items = [] for ProductModel in products: items.append( ProductGetMessage(id=ProductModel.key.id(), code=ProductModel.code, name=ProductModel.name, created_date=ProductModel.created_date)) return ProductCollectionMessage(items=items)
def search(self, request): """ Perform a search product. """ products = models.search(request) items = [] for ProductModel in products: items.append( ProductGetMessage( id=ProductModel.key.id(), code=ProductModel.code, name=ProductModel.name, created_date=ProductModel.created_date)) return ProductCollectionMessage(items=items)
def search(self, request): """ Performs a search of suppliers. """ suppliers = models.search(request) items = [] for supplierModel in suppliers: items.append( SupplierGetMessage(id=supplierModel.key.id(), name=supplierModel.name, email=supplierModel.email, phone=supplierModel.phone, location=supplierModel.location, created_date=supplierModel.created_date)) return SupplierCollectionMessage(items=items)
def search(self, request): """ Performs a search of suppliers. """ suppliers = models.search(request) items = [] for supplierModel in suppliers: items.append( SupplierGetMessage( id=supplierModel.key.id(), name=supplierModel.name, email=supplierModel.email, phone=supplierModel.phone, location=supplierModel.location, created_date=supplierModel.created_date)) return SupplierCollectionMessage(items=items)
def search(self, request): """Realiza uma pesquisa dos produtos cadastrados. """ logging.debug('Executando endpoint de pesquisa de produtos') #Obter a lista de produtos cadastrados products = models.search(request) #Declarando lista e convertendo model para message items = [] for ProductModel in products: items.append( ProductGetMessage(id=ProductModel.key.id(), code=ProductModel.code, name=ProductModel.name, created_date=ProductModel.created_date)) #Retornando produtos return ProductCollectionMessage(items=items)
def search(self, request): """ Search a customer by partial name. """ # Search customers = models.search(request) # Transport model to message items = [] for customerModel in customers: items.append( CustomerGetMessage(id=customerModel.key.id(), name=customerModel.name, email=customerModel.email, phone=customerModel.phone, location=customerModel.location, created_date=customerModel.created_date)) # Return return CustomerCollectionMessage(items=items)
def search(): if not request.json: abort(400) criteria = {} if 'email' in request.json: email = str(request.json['email']).strip().lower() criteria['email'] = email if 'last_name' in request.json: last_name = str(request.json['last_name']).strip().capitalize() criteria['last_name'] = last_name if 'zip_code' in request.json: zip_code = str(request.json['zip_code']).strip() criteria['zip_code'] = zip_code handler = models.search(criteria) return jsonify({'handlers': handler})
def search(self, request): """ Search a customer by partial name. """ # Search customers = models.search(request) # Transport model to message items = [] for customerModel in customers: items.append( CustomerGetMessage( id=customerModel.key.id(), name=customerModel.name, email=customerModel.email, phone=customerModel.phone, location=customerModel.location, created_date=customerModel.created_date)) # Return return CustomerCollectionMessage(items=items)
def output(request): res = models.search(request.GET['text']) page = 0 if ('page' in request.GET): page = int(request.GET['page']) - 1 plist = [(i + 1) for i in xrange(0, len(res) / 15 + ((len(res) % 15) > 0))] context = { 'text': request.GET['text'], 'people': res, 'count': len(res), 'page': page + 1, 'pfrom': page * 15, 'psize': len(res) / 15 + ((len(res) % 15) > 0), 'pto': min(page * 15 + 15, len(res)), 'plist': plist, } print context return render(request, 'result.html', context)
def search(self, request): """Realiza uma pesquisa dos produtos cadastrados. """ logging.debug('Executando endpoint de pesquisa de produtos') #Obter a lista de produtos cadastrados products = models.search(request) #Declarando lista e convertendo model para message items = [] for ProductModel in products: items.append( ProductGetMessage( id = ProductModel.key.id(), code = ProductModel.code, name = ProductModel.name, created_date = ProductModel.created_date)) #Retornando produtos return ProductCollectionMessage(items=items)
def search(self, request): """Realiza uma pesquisa dos fornecedores cadastrados. """ logging.debug('Executando endpoint de pesquisa de fornecedores') #Obter a lista de fornecedores cadastrados suppliers = models.search(request) #Declarando lista e convertendo model para message items = [] for supplierModel in suppliers: items.append( SupplierGetMessage( id = supplierModel.key.id(), name = supplierModel.name, email = supplierModel.email, phone = supplierModel.phone, location = supplierModel.location, created_date = supplierModel.created_date)) #Retornando fornecedores return SupplierCollectionMessage(items=items)
def search(): if not request.json: abort(400) criteria = {} if 'doc_id' in request.json: doc_id = str(request.json['doc_id']).strip().lower() criteria['doc_id'] = doc_id if 'doco_type' in request.json: doco_type = str(request.json['doco_type']).strip().upper() criteria['doco_type'] = doco_type if 'name' in request.json: name = str(request.json['name']).strip().capitalize() criteria['name'] = name if 'handler_id' in request.json: handler_id = request.json['handler_id'] if not (handler_id is None): str(handler_id).strip().lower() criteria['handler_id'] = handler_id if 'dog_id' in request.json: dog_id = request.json['dog_id'] if not (dog_id is None): str(dog_id).strip().lower() criteria['dog_id'] = dog_id if 'status' in request.json: status = str(request.json['status']).strip().upper() criteria['status'] = status documents = models.search(criteria) return jsonify({'documents': documents})
def getSearchResult(term): pageNum = int(request.args.get('page', 1)) searchDict = models.search(term, pageNum) return json.dumps(searchDict)
def search_view(): subject_id = request.form.get('subject_id', '') type = request.form.get('type', 'song') comments = search(subject_id, type) return {'comments': [comment.to_dict() for comment in comments]}
create_app() from models import Song, Artist, SEARCH_KEY, SUGGEST_KEY, search, suggest SEARCH_KEY = 'commentbox:search:{type}:{id}' SUGGEST_KEY = 'commentbox:suggest:{text}' songs = [song.name for song in Song.objects.all()] artists = [artist.name for artist in Artist.objects.all()] text_set = set() for name in songs + artists: for w in [name[:i] for i in range(1, len(name) + 1)]: text_set.add(w) # suggest预热 for text in text_set: print 'cache suggest', text suggest(text) # search预热 for song in Song.objects.all(): print 'cache search song', song.id search(song.id, 'song') for artist in Artist.objects.all(): print 'cache search artist', artist.id search(artist.id, 'artist')
def search_view(): subject_id = request.form.get('subject_id', '') type = request.form.get('type', 'movie') comment = search(subject_id, type) print comment return {'comment': [comment.to_dict()]}
def search_for(): folderForm = AddFolderForm() picForm = UpdateMetadataForm() searchForm = SearchForm(request.form) tagForm = AddTagForm() addTagForm = AddTag2PicForm() moveForm = MoveFolderForm() batchForm = BatchUpdateForm() editTagForm = EditTagForm() tag_list = Tag.query.filter_by(isFolder=False).all() children = [] pics = [] if request.method == "POST" and searchForm.submitSearch.data: # and searchForm.validate(): print "heeey" data = {} tb = searchForm.meta.model.__tablename__ tb_tags = Tag.__table__.name tag_lst = [] # go through searchForm and create a filter dictionary in the form of {"tablename.column": "data",...} to pass through search function located in models.py for field in searchForm: if field != searchForm.submitSearch and field.data and field.data != "None": if field != searchForm.tags and field != searchForm.folder: data[tb + '.' + field.name] = field.data else: tag_lst.append(str(field.data.id)) data[tb_tags + '.id'] = tag_lst print data if data: pics = search(data) print pics else: pics = {} return render_template('home.html', editTagForm=editTagForm, moveForm=moveForm, batchForm=batchForm, addTagForm=addTagForm, searchForm=searchForm, picForm=picForm, tagForm=tagForm, folderForm=folderForm, tag_list=tag_list, pics=pics, folders=[]) ''' print "searchForm" print searchForm.submitSearch.data print searchForm.validate() ''' return render_template('home.html', moveForm=moveForm, batchForm=batchForm, editTagForm=editTagForm, searchForm=searchForm, addTagForm=addTagForm, tagForm=tagForm, picForm=picForm, folderForm=folderForm, pics=pics, folders=children)
def search_all_endpoint(searchTerms): return jsonify({"searchResults": search(searchTerms)})