예제 #1
0
def search_view(request):
    if request.method == 'GET' and 'q' in request.GET:
        return {
            'query': request.GET['q'],
            'countries': dict((v, k) for k, v in cctlds.iteritems()),
            'result': zeitgeist_borders.google_instants(request.GET['q'])
        }
    else:
        return {}
예제 #2
0
def search_view(request):
    if request.method == 'GET' and 'q' in request.GET:
        return {'query': request.GET['q'],
                'countries': dict((v, k)
                                  for k, v
                                  in cctlds.iteritems()),
                'result':
                    zeitgeist_borders.google_instants(request.GET['q'])}
    else:
        return {}
def google_instants(query):
    q = Queue()
    result = {}
    for country, tld in cctlds.iteritems():
        Thread(target=google_instant, args=(q, country, tld, query)).start()
    waiting = len(cctlds)
    while waiting > 0:
        country, suggestions = q.get()
        result[country] = suggestions
        waiting -= 1
    return result
def google_instants(query):
    q = Queue()
    result = {}
    for country, tld in cctlds.iteritems():
        Thread(target=google_instant, args=(q, country, tld, query)).start()
    waiting = len(cctlds)
    while waiting > 0:
        country, suggestions = q.get()
        result[country] = suggestions
        waiting -= 1
    return result