From 90aba00ca0681ca8d320eb5d0ee5c8c23867eaf5 Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Tue, 10 Feb 2015 15:03:21 -0800 Subject: [PATCH] not_found: catch NotFoundException from any part of handle_request, not just indexing.. allows for more flexible usage with cdx iterators that are lazily evaluated on replay --- pywb/webapp/handlers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pywb/webapp/handlers.py b/pywb/webapp/handlers.py index 3ad730ce..d71296ed 100644 --- a/pywb/webapp/handlers.py +++ b/pywb/webapp/handlers.py @@ -69,7 +69,10 @@ class SearchPageWbUrlHandler(WbUrlHandler): else: wbrequest.final_mod = 'tf_' - return self.handle_request(wbrequest) + try: + return self.handle_request(wbrequest) + except NotFoundException as nfe: + return self.handle_not_found(wbrequest, nfe) def get_top_frame_params(self, wbrequest, mod=''): embed_url = wbrequest.wb_url.to_str(mod=mod, url='') @@ -133,10 +136,7 @@ class WBHandler(SearchPageWbUrlHandler): self.fallback_handler = handler_dict.get(self.fallback_name) def handle_request(self, wbrequest): - try: - cdx_lines, output = self.index_reader.load_for_request(wbrequest) - except NotFoundException as nfe: - return self.handle_not_found(wbrequest, nfe) + cdx_lines, output = self.index_reader.load_for_request(wbrequest) if output != 'text' and wbrequest.wb_url.is_replay(): return self.handle_replay(wbrequest, cdx_lines)