Ronny Pfannschmidt avatar Ronny Pfannschmidt committed e41a56a

various code cleanups

Comments (0)

Files changed (3)


 def inject_style():
-    style, css = get_style(request)
+    from lodgeit.lib.highlighting import get_style
+    style, css = get_style(flask.request)
     return {'style': style, 'css': css}
 def inject_new_replies():
     if flask.request.method=='GET':
         from lodgeit.models import Paste
-        return {'new_replies': Paste.fetch_replies()}
+        return {'get_new_replies': Paste.fetch_replies}


 except ImportError:
     import ImageFont, ImageDraw, Image, ImageChops, ImageColor
 from werkzeug import Response
-#from lodgeit import local
     from hashlib import sha1
 except ImportError:
     from sha import new as sha1
+from flask import request, session
 resource_path = abspath(join(dirname(__file__), pardir, 'res'))
     request by using the secret key.
     if hashed_solution is None:
-        hashed_solution = local.request.session.get('captcha_id')
+        hashed_solution = session.get('captcha_id')
         if hashed_solution is None:
             return False
     return hashed_solution == calculate_hash(solution, secret_key)
 def calculate_hash(solution, secret_key=None):
     """Calculate the hash."""
     if secret_key is None:
-        secret_key = local.application.secret_key
+        secret_key = app.config['SECRET_KEY']
     return sha1('%s|%s' % (
         response = Response(mimetype='image/png')
         self.render_image(size=None).save(, 'PNG')
         if set_cookie:
-            local.request.session['captcha_id'] = self.hash_solution()
+            session['captcha_id'] = self.hash_solution()
         return response


         """Get the new replies for the ower of a request and flag them
         as handled.
         ids = db.session.query(Paste.paste_id) \
                         .filter(Paste.user_hash == request.user_hash)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.