1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fix for NoneType issues related to redirects

This commit is contained in:
echel0n 2014-06-17 14:25:35 -07:00
parent 4513525cc4
commit b47b2e1f58

View File

@ -81,7 +81,7 @@ from lib import adba
from Cheetah.Template import Template from Cheetah.Template import Template
from tornado import gen, autoreload from tornado import gen, autoreload
from tornado.web import RequestHandler, HTTPError, asynchronous from tornado.web import RequestHandler, RedirectHandler, HTTPError, asynchronous
from tornado.ioloop import IOLoop from tornado.ioloop import IOLoop
# def _handle_reverse_proxy(): # def _handle_reverse_proxy():
@ -134,14 +134,8 @@ def authenticated(handler_class):
handler_class._execute = wrap_execute(handler_class._execute) handler_class._execute = wrap_execute(handler_class._execute)
return handler_class return handler_class
class RedirectHandler(RequestHandler):
def get(self, path, **kwargs):
self.redirect(path, permanent=True)
@authenticated @authenticated
class IndexHandler(RedirectHandler): class IndexHandler(RequestHandler):
def __init__(self, application, request, **kwargs): def __init__(self, application, request, **kwargs):
super(IndexHandler, self).__init__(application, request, **kwargs) super(IndexHandler, self).__init__(application, request, **kwargs)
global req_headers global req_headers
@ -206,24 +200,23 @@ class IndexHandler(RedirectHandler):
raise HTTPError(404) raise HTTPError(404)
@asynchronous def redirect(self, url, permanent=False, status=None):
def get(self, *args, **kwargs): if not self._transforms:
try: self._transforms = []
resp = self._dispatch()
if resp: super(IndexHandler, self).redirect(url, permanent, status)
self.finish(resp)
except Exception as e:
logger.log(ex(e), logger.ERROR)
logger.log(u"Traceback: " + traceback.format_exc(), logger.DEBUG)
@asynchronous @asynchronous
def post(self, *args, **kwargs): def get(self, *args, **kwargs):
try: try:
self.finish(self._dispatch()) self.finish(self._dispatch())
except Exception as e: except Exception as e:
logger.log(ex(e), logger.ERROR) logger.log(ex(e), logger.ERROR)
logger.log(u"Traceback: " + traceback.format_exc(), logger.DEBUG) logger.log(u"Traceback: " + traceback.format_exc(), logger.DEBUG)
def post(self, *args, **kwargs):
return self._dispatch()
def robots_txt(self, *args, **kwargs): def robots_txt(self, *args, **kwargs):
""" Keep web crawlers out """ """ Keep web crawlers out """
self.set_header('Content-Type', 'text/plain') self.set_header('Content-Type', 'text/plain')
@ -1472,6 +1465,7 @@ class ConfigGeneral(IndexHandler):
else: else:
ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE))
self.redirect("/home/")
class ConfigSearch(IndexHandler): class ConfigSearch(IndexHandler):
def index(self, *args, **kwargs): def index(self, *args, **kwargs):