diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2014-02-09 01:12:44 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2014-02-09 01:12:44 +0100 |
commit | 56b9d3f4221fa8bf5679ba78731b92aacea50a4d (patch) | |
tree | f6fd2f20c645919116c1556093837f85f1741fc4 | |
parent | c118e804f949544979687ee865d1471e624ca801 (diff) |
Return rendered templates as lists.
-rwxr-xr-x | fbin.py | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -240,7 +240,7 @@ class Application(object): form['file'].file.delete = True if user or settings.allow_anonymous_uploads: start_response('200 OK', [('Content-Type', 'text/html')]) - return str(templates.upload(searchList = {'settings': settings, 'user': user})) + return [str(templates.upload(searchList = {'settings': settings, 'user': user}))] else: return self.redirect(environ, start_response, 'l') @@ -294,7 +294,7 @@ class Application(object): return ['OK {hash}'.format(hash = hash)] else: start_response('200 OK', [('Content-Type', 'text/html')]) - return str(templates.uploaded(searchList = { + return [str(templates.uploaded(searchList = { 'settings': settings, 'user': user, 'hash': hash, @@ -302,7 +302,7 @@ class Application(object): 'ext': os.path.splitext(filename)[1], 'scheme': environ['wsgi.url_scheme'], 'host': environ['HTTP_HOST'], - })) + }))] def login(self, environ, start_response, path): user = self.validate_cookie(environ) @@ -318,26 +318,26 @@ class Application(object): if 'request_token' in form and 'verified' in form: if form.getvalue('verified') == '0': start_response('200 OK', [('Content-Type', 'text/html')]) - return str(templates.login(searchList = { + return [str(templates.login(searchList = { 'settings': settings, 'user': None, 'error': 'Login was declined.', 'loggedin': False, 'next': form.getvalue('next'), - })) + }))] request_token = form.getvalue('request_token') try: token = self.jab.request_user_token(request_token, settings.jab_identifier, settings.jab_name) jab_user = self.jab.get_user_by_token(token, settings.jab_identifier, environ['REMOTE_ADDR']) except jab.client.InvalidCredentialsError: start_response('200 OK', [('Content-Type', 'text/html')]) - return str(templates.login(searchList = { + return [str(templates.login(searchList = { 'settings': settings, 'user': None, 'error': 'Failed to request login: invalid token or user.', 'loggedin': False, 'next': form.getvalue('next'), - })) + }))] # FIXME: Don't use the username as key for jab users. user = self.get_user_by_name(jab_user['username']) if not user: @@ -349,13 +349,13 @@ class Application(object): ('Content-Type', 'text/html'), ('Set-Cookie', c['token'].OutputString()) ]) - return str(templates.login(searchList = { + return [str(templates.login(searchList = { 'settings': settings, 'user': user, 'error': None, 'loggedin': True, 'next': form.getvalue('next'), - })) + }))] if user: rememberme = 'rememberme' in form @@ -432,12 +432,12 @@ class Application(object): def help(self, environ, start_response, path): user = self.validate_cookie(environ) start_response('200 OK', [('Content-Type', 'text/html')]) - return str(templates.help(searchList = { + return [str(templates.help(searchList = { 'settings': settings, 'user': user, 'scheme': environ['wsgi.url_scheme'], 'host': environ['HTTP_HOST'], - })) + }))] def my_files(self, environ, start_response, path): user = self.validate_cookie(environ) @@ -446,12 +446,12 @@ class Application(object): return [] files = self.get_files(user) start_response('200 OK', [('Content-Type', 'text/html')]) - return str(templates.my(searchList = { + return [str(templates.my(searchList = { 'settings': settings, 'user': user, 'files': files, 'total_size': db.File.pretty_size(sum([f.get_size() for f in files])), - })) + }))] def images(self, environ, start_response, path): user = self.validate_cookie(environ) @@ -460,12 +460,12 @@ class Application(object): return [] files = [f for f in self.get_files(user) if f.is_image()] start_response('200 OK', [('Content-Type', 'text/html')]) - return str(templates.images(searchList = { + return [str(templates.images(searchList = { 'settings': settings, 'user': user, 'files': files, 'total_size': db.File.pretty_size(sum([f.get_size() for f in files])), - })) + }))] def thumb(self, environ, start_response, path): hash = path[1] @@ -508,12 +508,12 @@ class Application(object): return [] else: start_response('200 OK', [('Content-Type', 'text/html')]) - return str(templates.delete(searchList = { + return [str(templates.delete(searchList = { 'settings': settings, 'user': user, 'hash': hash, 'filename': file.filename, - })) + }))] def api(self, environ, start_response, path): def error(msg): |