Commits

Ronny Pfannschmidt committed 0993f12

lots of cleanups

Comments (0)

Files changed (6)

lodgeit/controllers/pastes.py

 def show_all(page=1):
     """Paginated list of pages."""
     def link(page):
-        if page == 1:
-            return request.get_url('pastes/show_all')
-        return request.get_url('pastes/show_all', page=page)
+        return url_for('.show_all', page=page)
 
     form_args = request.args
     query = Paste.find_all()
     from lodgeit import i18n
     for key, value in i18n.list_languages():
         if key == lang:
-            request.set_language(lang)
+            session['language'] = lang
             break
     return redirect(request.headers.get('HTTP_REFERER') or url_for('pastes.new_paste'))
 

lodgeit/lib/diff.py

 import re
 import time
 from cgi import escape
-try:
-    all
-except NameError:
-    def all(iterable):
-        for element in iterable:
-            if not element:
-                return False
-        return True
 
 
 def prepare_udiff(udiff):

lodgeit/models.py

         """Get the new replies for the ower of a request and flag them
         as handled.
         """
-        
+        if 'user_hash' not in session:
+            return []
         ids = db.session.query(Paste.paste_id) \
-                        .filter(Paste.user_hash == request.user_hash)
+                        .filter(Paste.user_hash == session['user_hash'])
 
         paste_list = db.session.query(Paste.paste_id).filter(db.and_(
             Paste.parent_id.in_(ids),

lodgeit/templates/layout.html

       </ul> #}
       <div class="content">
         <h2>{{ page_title|e }}</h2>
-        {% - set new_replies = get_new_replies() %}
+        {%- set new_replies = get_new_replies() %}
         {%- if new_replies %}
           <div class="notification">
             <h3>{% trans %}Someone Replied To Your Paste{% endtrans %}</h3>

lodgeit/templates/show_all.html

   {% if pastes %}
   <ul class="paste_list">
   {% for paste in pastes %}
-    <li class="{{ loop.cycle('even', 'odd') }}"><p><a href="{{ url('pastes/show_paste', identifier=paste.identifier)
+    <li class="{{ loop.cycle('even', 'odd') }}"><p><a href="{{ url_for('pastes.show_paste', identifier=paste.identifier)
         }}">Paste #{{ paste.identifier }}</a>,
         {% trans date=paste.pub_date|datetimeformat %}pasted on {{ date }}{% endtrans %}</p>
-      {{ paste.render_preview() }}</li>
+      {{ paste.render_preview()|safe }}</li>
   {%- endfor %}
   </ul>
   {% else %}
   <strong>{% trans %}No pastes found{% endtrans %}</strong>
   {% endif %}
   <div class="pagination">
-    {{ pagination }}
+    {{ pagination|safe }}
   </div>
 {% endblock %}
     :copyright: 2007-2008 by Christopher Grebs.
     :license: BSD
 """
-import time
-from os import path
 
-from werkzeug import Request as RequestBase, 
-
-class Request(RequestBase):
+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.