From 4bb496de8ebfa0577948e8acd75e7dacc0911b21 Mon Sep 17 00:00:00 2001 From: Jason Moiron Date: Sun, 8 Jan 2012 16:03:41 -0500 Subject: [PATCH] fix a migratedb issue with flask-login, fix the blog post list by taking out ill conceived "latest" --- jmoiron/blog/views.py | 2 +- manage.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/jmoiron/blog/views.py b/jmoiron/blog/views.py index 2a3ad32..46e3f96 100644 --- a/jmoiron/blog/views.py +++ b/jmoiron/blog/views.py @@ -23,7 +23,7 @@ def show_page(num): p.urlfunc = lambda num: url_for("blog.show_page", num=num) if not p.exists: abort(404) - posts = Post.latest()[p.slice()] + posts = Post.find({"is_published": True}).order_by("-timestamp")[p.slice()] return render_template("blog/index.html", posts=posts, page=p) @blog.route("/") diff --git a/manage.py b/manage.py index 955d6cb..79c4384 100755 --- a/manage.py +++ b/manage.py @@ -46,6 +46,13 @@ def create_indexes(): @script.command def migratedb(dumpfile=None): """Run a migration from an SQL database.""" + # remove the flask-login context processor as it messes up rendering + # templates outside of a regular run-created context + from flaskext import login + procs = app.template_context_processors[None] + if login._user_context_processor in procs: + procs.remove(login._user_context_processor) + print 'Flushing current mongo database...' flushdb() if dumpfile: @@ -65,7 +72,7 @@ def migratedb(dumpfile=None): db['comment'].insert(comments['comments']) db['banned_ip'].insert(comments['bannedips']) print 'Resetting blog comments to use oids..' - from blog.models import Post + from jmoiron.blog.models import Post mapping = dict([(c['id'], c['_id']) for c in db.comment.find()]) for post in Post.find({'comments': {'$ne': []}}): post.comments = [mapping[c] for c in post['comments']] @@ -81,7 +88,7 @@ def migratedb(dumpfile=None): @script.command def rerender_entries(source_tag=None): """Rerender stream entries.""" - from stream.models import Entry + from jmoiron.stream.models import Entry if source_tag: entries = Entry.find({'source_tag': source_tag}) else: