diff --git a/pywb/framework/memento.py b/pywb/framework/memento.py index 4b3eecc1..d7221adb 100644 --- a/pywb/framework/memento.py +++ b/pywb/framework/memento.py @@ -11,15 +11,13 @@ LINK_FORMAT = 'application/link-format' #================================================================= class MementoReqMixin(object): def _parse_extra(self): - self.is_timegate = False - if not self.wb_url: return if self.wb_url.type != self.wb_url.LATEST_REPLAY: return - self.is_timegate = True + self.options['is_timegate'] = True accept_datetime = self.env.get('HTTP_ACCEPT_DATETIME') if not accept_datetime: @@ -48,7 +46,7 @@ class MementoRespMixin(object): if not wbrequest or not wbrequest.wb_url: return - is_timegate = wbrequest.is_timegate + is_timegate = wbrequest.options.get('is_timegate', False) if is_timegate: self.status_headers.headers.append(('Vary', 'accept-datetime')) @@ -59,7 +57,7 @@ class MementoRespMixin(object): is_memento = False # otherwise, if in proxy mode, then always a memento - elif wbrequest.is_proxy: + elif wbrequest.options['is_proxy']: is_memento = True # otherwise only for replay @@ -80,7 +78,7 @@ class MementoRespMixin(object): link.append(self.make_link(req_url, 'original')) # for now, include timemap only in non-proxy mode - if not wbrequest.is_proxy and (is_memento or is_timegate): + if not wbrequest.options['is_proxy'] and (is_memento or is_timegate): link.append(self.make_timemap_link(wbrequest)) if is_memento and not is_timegate: diff --git a/pywb/framework/wbrequestresponse.py b/pywb/framework/wbrequestresponse.py index 85ff2eb8..0f1a9f32 100644 --- a/pywb/framework/wbrequestresponse.py +++ b/pywb/framework/wbrequestresponse.py @@ -78,12 +78,11 @@ class WbRequest(object): self.referrer = env.get('HTTP_REFERER') - self.is_ajax = self._is_ajax() + self.options = dict() + self.options['is_ajax'] = self._is_ajax() + self.options['is_proxy'] = is_proxy self.query_filter = [] - - self.is_proxy = is_proxy - self.custom_params = {} # PERF diff --git a/pywb/webapp/handlers.py b/pywb/webapp/handlers.py index 5c227b9f..ecc477bc 100644 --- a/pywb/webapp/handlers.py +++ b/pywb/webapp/handlers.py @@ -8,8 +8,6 @@ from pywb.utils.loaders import BlockLoader from pywb.framework.basehandlers import BaseHandler, WbUrlHandler from pywb.framework.wbrequestresponse import WbResponse -import logging - #================================================================= # Standard WB Handler diff --git a/pywb/webapp/replay_views.py b/pywb/webapp/replay_views.py index ee88219d..c113d733 100644 --- a/pywb/webapp/replay_views.py +++ b/pywb/webapp/replay_views.py @@ -66,8 +66,9 @@ class BaseContentView(object): # render top level frame if in frame mode # (not supported in proxy mode) if (self.is_frame_mode and - not wbrequest.is_proxy and - not wbrequest.wb_url.mod): + not wbrequest.wb_url.mod and + not wbrequest.options['is_proxy'] and + not wbrequest.options.get('is_timegate', False)): embed_url = wbrequest.wb_url.to_str(mod=self._mp_mod) timestamp = datetime_to_timestamp(datetime.datetime.utcnow()) @@ -259,12 +260,10 @@ class ReplayView(BaseContentView): return content def _redirect_if_needed(self, wbrequest, cdx): - if wbrequest.is_proxy: + if wbrequest.options['is_proxy']: return None - # todo: generalize this? - redir_needed = (hasattr(wbrequest, 'is_timegate') and - wbrequest.is_timegate) + redir_needed = (wbrequest.options.get('is_timegate', False)) if not redir_needed and self.redir_to_exact: redir_needed = (cdx['timestamp'] != wbrequest.wb_url.timestamp)