Skip to content
Browse files

fix a migratedb issue with flask-login, fix the blog post list by tak…

…ing out ill conceived "latest"
  • Loading branch information...
1 parent bfccddc commit 4bb496de8ebfa0577948e8acd75e7dacc0911b21 @jmoiron committed Jan 8, 2012
Showing with 10 additions and 3 deletions.
  1. +1 −1 jmoiron/blog/views.py
  2. +9 −2 manage.py
View
2 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("/<slug>")
View
11 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:

0 comments on commit 4bb496d

Please sign in to comment.
Something went wrong with that request. Please try again.