fix exception when using FileDisplay (-t), class was missing the redirect_by_default method

moved common stuff to CommonDisplayMixin class.
This commit is contained in:
Thomas Waldmann 2015-01-23 04:20:47 +01:00
parent 16e9d887ab
commit 8d32a9a4d8

View file

@ -10,7 +10,26 @@ WIDTH = 72
HEIGHT = 20
class NcursesDisplay(object):
class CommonDisplayMixin(object):
"""methods common to both NcursesDisplay and FileDisplay"""
def redirect_by_default(self):
choices = [
("Easy", "Allow both HTTP and HTTPS access to these sites"),
("Secure", "Make all requests redirect to secure HTTPS access")]
result = self.generic_menu(
"Please choose whether HTTPS access is required or optional.",
choices, "Please enter the appropriate number")
if result[0] != OK:
return False
# different answer for each type of display
return str(result[1]) == "Secure" or result[1] == 1
class NcursesDisplay(CommonDisplayMixin):
zope.interface.implements(interfaces.IDisplay)
def __init__(self, width=WIDTH, height=HEIGHT):
@ -85,23 +104,8 @@ class NcursesDisplay(object):
print text
self.dialog.msgbox(text, width=self.width, height=self.height)
def redirect_by_default(self):
choices = [
("Easy", "Allow both HTTP and HTTPS access to these sites"),
("Secure", "Make all requests redirect to secure HTTPS access")]
result = self.generic_menu(
"Please choose whether HTTPS access is required or optional.",
choices, "Please enter the appropriate number")
if result[0] != OK:
return False
# different answer for each type of display
return str(result[1]) == "Secure" or result[1] == 1
class FileDisplay(object):
class FileDisplay(CommonDisplayMixin):
zope.interface.implements(interfaces.IDisplay)
def __init__(self, outfile):