Use finish instead of write

This commit is contained in:
Ruud
2013-08-31 15:32:45 +02:00
parent 689feb78d0
commit 1b03c7e474
3 changed files with 9 additions and 8 deletions
+3 -3
View File
@@ -25,7 +25,7 @@ class WebHandler(RequestHandler):
if not views.get(route):
page_not_found(self)
return
self.write(views[route]())
self.finish(views[route]())
def addView(route, func, static = False):
views[route] = func
@@ -64,7 +64,7 @@ class KeyHandler(RequestHandler):
if (self.get_argument('u') == md5(username) or not username) and (self.get_argument('p') == password or not password):
api = Env.setting('api_key')
self.write({
self.finish({
'success': api is not None,
'api_key': api
})
@@ -81,5 +81,5 @@ def page_not_found(rh):
time.sleep(0.1)
rh.set_status(404)
rh.write('Wrong API key used')
rh.finish('Wrong API key used')
+3 -3
View File
@@ -49,7 +49,7 @@ class ApiHandler(RequestHandler):
def get(self, route, *args, **kwargs):
route = route.strip('/')
if not api.get(route):
self.write('API call doesn\'t seem to exist')
self.finish('API call doesn\'t seem to exist')
return
kwargs = {}
@@ -68,11 +68,11 @@ class ApiHandler(RequestHandler):
jsonp_callback = self.get_argument('callback_func', default = None)
if jsonp_callback:
self.write(str(jsonp_callback) + '(' + json.dumps(result) + ')')
self.finish(str(jsonp_callback) + '(' + json.dumps(result) + ')')
elif isinstance(result, (tuple)) and result[0] == 'redirect':
self.redirect(result[1])
else:
self.write(result)
self.finish(result)
def addApiView(route, func, static = False, docs = None, **kwargs):
+3 -2
View File
@@ -19,7 +19,7 @@ log = CPLog(__name__)
class CoreNotifier(Notification):
m_lock = threading.Lock()
m_lock = None
def __init__(self):
super(CoreNotifier, self).__init__()
@@ -57,6 +57,7 @@ class CoreNotifier(Notification):
self.messages = []
self.listeners = []
self.m_lock = threading.Lock()
def clean(self):
@@ -222,7 +223,7 @@ class CoreNotifier(Notification):
recent = []
try:
index = map(itemgetter('message_id'), self.messages).index(last_id)
recent = self.messages[index+1:]
recent = self.messages[index + 1:]
except:
pass