From aa6689f375242c7432b0677697c2ef8bb57c53d7 Mon Sep 17 00:00:00 2001 From: joechong88 Date: Tue, 31 Dec 2013 16:17:49 +0800 Subject: [PATCH] Update the re.search to use string Update the re.search function in line 19 to use a str(s['from ') and str(s['to']). This handles an error when the To has no emails addresses. --- ch03/web/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch03/web/index.py b/ch03/web/index.py index 26e3975..419f603 100644 --- a/ch03/web/index.py +++ b/ch03/web/index.py @@ -16,7 +16,7 @@ def sent_counts(): sent_counts = db['sent_counts'].find() results = {} results['keys'] = 'from', 'to', 'total' - results['values'] = [[s['from'], s['to'], s['total']] for s in sent_counts if re.search('apache', s['from']) or re.search('apache', s['to'])] + results['values'] = [[s['from'], s['to'], s['total']] for s in sent_counts if re.search('apache', str(s['from'])) or re.search('apache', str(s['to']))] results['values'] = results['values'][0:17] return render_template('table.html', results=results)