1. Christopher Grebs
  2. lodgeit-main

Commits

Ronny Pfannschmidt  committed e41a56a

various code cleanups

  • Participants
  • Parent commits 1fde7de
  • Branches flask-port

Comments (0)

Files changed (3)

File lodgeit/application.py

View file
 
 @app.context_processor
 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}
 
 
 @app.errorhandler(404)

File lodgeit/lib/captcha.py

View file
 except ImportError:
     import ImageFont, ImageDraw, Image, ImageChops, ImageColor
 from werkzeug import Response
-#from lodgeit import local
 
 try:
     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' % (
         secret_key,
         solution.encode('utf-8')
         response = Response(mimetype='image/png')
         self.render_image(size=None).save(response.stream, 'PNG')
         if set_cookie:
-            local.request.session['captcha_id'] = self.hash_solution()
+            session['captcha_id'] = self.hash_solution()
         return response
 
 

File lodgeit/models.py

View file
         """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)