diff --git a/pywb/webapp/test/test_view_filters.py b/pywb/webapp/test/test_view_filters.py new file mode 100644 index 00000000..1df32d5f --- /dev/null +++ b/pywb/webapp/test/test_view_filters.py @@ -0,0 +1,20 @@ +""" +>>> format_ts('201412261010') +'Fri, Dec 26 2014 10:10:59' + +>>> format_ts('201412261010', '%s') +1419617459000 + +>>> is_wb_handler(DebugEchoHandler()) +False + + +""" + +from pywb.webapp.views import format_ts, is_wb_handler +from pywb.webapp.handlers import DebugEchoHandler + + +if __name__ == "__main__": + import doctest + doctest.testmod() diff --git a/pywb/webapp/views.py b/pywb/webapp/views.py index 4d9cdd6d..1f3a7e4b 100644 --- a/pywb/webapp/views.py +++ b/pywb/webapp/views.py @@ -23,11 +23,7 @@ class template_filter(object): Otherwise, the func name is the filter name """ def __init__(self, param=None): - if hasattr(param, '__call__'): - self.name = None - self.__call__(param) - else: - self.name = param + self.name = param def __call__(self, func): name = self.name @@ -40,7 +36,7 @@ class template_filter(object): #================================================================= # Filters -@template_filter +@template_filter() def format_ts(value, format_='%a, %b %d %Y %H:%M:%S'): value = timestamp_to_datetime(value) if format_ == '%s': @@ -55,17 +51,11 @@ def get_urlsplit(url): return split -@template_filter() -def request_hostname(env): - return env.get('HTTP_HOST', 'localhost') - - @template_filter() def is_wb_handler(obj): if not hasattr(obj, 'handler'): return False - #return isinstance(obj.handler, WBHandler) return obj.handler.__class__.__name__ == "WBHandler"