rug-compling/alpinocorpus-python — Issue #1: unicode in queries
Author: pebbe
Created: 2012-02-02 19:10:11+00:00
State: open

server.py kan niet omgaan met unicode-tekens in een query. Hier is een patch:

{{{
--- ../alpinocorpus-python/examples/server.py	2012-02-02 18:19:46.000000000 +0100
+++ server.py	2012-02-02 20:05:05.000000000 +0100
@@ -63,7 +63,7 @@
params = web.input()
contents = False
if params.has_key('query'):
- gen = c.query(params['query'])
+ gen = c.query(params['query'].encode('utf-8'))
if params.has_key('contents') and params.get('contents') == '1':
contents = True
else:
@@ -92,7 +92,7 @@

# Do we want to highlight something?
if params.has_key('markerQuery') and params.has_key('markerAttr') and params.has_key('markerValue'):
- markerQueries = [alpinocorpus.MarkerQuery(params['markerQuery'],
+ markerQueries = [alpinocorpus.MarkerQuery(params['markerQuery'].encode('utf-8'),
params['markerAttr'], params['markerValue'])]
else:
markerQueries = []
@@ -101,7 +101,7 @@

# Was a query provided?
if params.has_key('query'):
- gen = c.queryWithStylesheet(params['query'], web.data(), markerQueries)
+ gen = c.queryWithStylesheet(params['query'].encode('utf-8'), web.data(), markerQueries)
else:
gen = c.entriesWithStylesheet(web.data(), markerQueries)

@@ -125,7 +125,7 @@

# Was there a request to mark entries?
if params.has_key('markerQuery') and params.has_key('markerAttr') and params.has_key('markerValue'):
- queries = [alpinocorpus.MarkerQuery(params['markerQuery'],
+ queries = [alpinocorpus.MarkerQuery(params['markerQuery'].encode('utf-8'),
params['markerAttr'], params['markerValue'])]
data = c.readMarkQueries(entry, queries)
else:
@@ -149,7 +149,7 @@

# Was there a request to mark entries?
if params.has_key('query'):
- query = params.get('query')
+ query = params.get('query').encode('utf-8')
if c.validQuery(query):
return '1'
else:
}}}