summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alot/buffers/search.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/alot/buffers/search.py b/alot/buffers/search.py
index 20c0ae47..700ce69f 100644
--- a/alot/buffers/search.py
+++ b/alot/buffers/search.py
@@ -3,6 +3,7 @@
# For further details see the COPYING file
import asyncio
+from functools import partial
import urwid
@@ -18,7 +19,8 @@ class IterWalker(urwid.ListWalker):
ThreadlineWidget widgets for displaying
"""
- _dbman = None
+ _threads = None
+ _wgt_factory = None
_iter_done = False
@@ -29,9 +31,9 @@ class IterWalker(urwid.ListWalker):
_focus = None
- def __init__(self, threads, dbman):
- self._threads = threads
- self._dbman = dbman
+ def __init__(self, threads, wgt_factory):
+ self._threads = threads
+ self._wgt_factory = wgt_factory
self._tids = []
self._wgts = {}
@@ -51,7 +53,7 @@ class IterWalker(urwid.ListWalker):
# make sure an exception while constructing the widget does not get
# swallowed by urwid
try:
- self._wgts[pos] = ThreadlineWidget(self._tids[pos], self._dbman)
+ self._wgts[pos] = self._wgt_factory(self._tids[pos])
except (KeyError, IndexError, TypeError) as e:
raise ValueError('Exception while constructing threadline widget') from e
@@ -163,9 +165,10 @@ class SearchBuffer(Buffer):
self._result_count = None
self._thread_count = None
- threads = self.dbman.get_threads(self.querystring, self.sort_order,
- exclude_tags)
- threadlist = IterWalker(threads, self.dbman)
+ threads = self.dbman.get_threads(self.querystring, self.sort_order,
+ exclude_tags)
+ wgt_factory = partial(ThreadlineWidget, dbman = self.dbman)
+ threadlist = IterWalker(threads, wgt_factory)
# check that the query is well-formed
try: