Commits

Ronny Pfannschmidt committed ecde997

more cleanup

  • Participants
  • Parent commits 0993f12
  • Branches flask-port

Comments (0)

Files changed (4)

File lodgeit/application.py

 
 from .i18n import list_languages
 
+@babel.localeselector
+def get_lang():
+    try:
+        return flask.session['lang']
+    except KeyError:
+        #XXX: hardcoded
+        return flask.request.accept_languages.best_match(['de', 'en'])
 
 @app.context_processor
 def inject_i18n_languages():

File lodgeit/i18n/__init__.py

     :license: GNU GPL.
 """
 import os
-from babel import Locale, dates, UnknownLocaleError
+from babel import Locale, UnknownLocaleError
 from babel.support import Translations
 
 

File lodgeit/models.py

         with their unique hash and public with the paste id.
         """
         if isinstance(identifier, basestring) and not identifier.isdigit():
-            return Paste.query.filter(Paste.private_id == identifier).first()
-        return Paste.query.filter(db.and_(
-            Paste.paste_id == int(identifier),
-            Paste.private_id == None)).first()
+            return Paste.query.filter_by(private_id=identifier).first()
+        return Paste.query.filter_by(
+            paste_id=int(identifier),
+            private_id=None).first()
 
     @staticmethod
     def find_all():

File lodgeit/utils.py

-# -*- coding: utf-8 -*-
-"""
-    lodgeit.utils
-    ~~~~~~~~~~~~~
-
-    Serveral utilities used by LodgeIt.
-
-    :copyright: 2007-2008 by Christopher Grebs.
-    :license: BSD
-"""
-
-class Request:
-    """Subclass of the `Request` object. automatically creates a new
-    `user_hash` and sets `first_visit` to `True` if it's a new user.
-    It also stores the engine and dbsession on it.
-    """
-    charset = 'utf-8'
-
-    def __init__(self, environ, urls):
-        # language is limited to english until translations are ready
-        lang = session.get('locale')
-        if lang is None:
-            lang = 'en'
-
-    def set_language(self, lang):
-        self.session['locale'] = lang
-
-