def livereload(): db.create_all() server = Server(app) server.watch("gather/*.py") server.watch("gather/templates/*.html") server.watch("gather/assets/stylesheets/*.sass") server.watch("gather/assets/javascripts/*.coffee") server.serve(port=8000)
def create_all(): db.create_all()
for pbb_topic in mongo_database.topics.find(sort=[('last_reply_time', 1)]): topic = Topic( title=pbb_topic["title"], content=pbb_topic["content"], author=Account.query.filter_by( username=pbb_topic["author"].lower()).first(), node=Node.query.filter_by(slug=pbb_topic["node"]).first(), created=timestamp_to_datetime(pbb_topic["created"]), updated=timestamp_to_datetime(pbb_topic["last_reply_time"])) print "Migrating Topic %s by %s" % (topic.title, topic.author.username) db.session.add(topic) db.session.commit() for pbb_reply in mongo_database.replies.find( {'topic': str(pbb_topic["_id"])}, sort=[('index', 1)]): reply = Reply(content=pbb_reply["content"], author=Account.query.filter_by( username=pbb_reply["author"].lower()).first(), topic=topic, created=timestamp_to_datetime(pbb_reply["created"])) print "Migrating Reply %s by %s" % (reply.content, reply.author.username) db.session.add(reply) db.session.commit() with app.app_context(): db.drop_all() db.create_all() main()
for pbb_topic in mongo_database.topics.find(sort=[('last_reply_time', 1)]): topic = Topic( title=pbb_topic["title"], content=pbb_topic["content"], author=Account.query.filter_by(username=pbb_topic["author"].lower()).first(), node=Node.query.filter_by(slug=pbb_topic["node"]).first(), created=timestamp_to_datetime(pbb_topic["created"]), updated=timestamp_to_datetime(pbb_topic["last_reply_time"]) ) print "Migrating Topic %s by %s" % (topic.title, topic.author.username) db.session.add(topic) db.session.commit() for pbb_reply in mongo_database.replies.find({'topic': str(pbb_topic["_id"])}, sort=[('index', 1)]): reply = Reply( content=pbb_reply["content"], author=Account.query.filter_by(username=pbb_reply["author"].lower()).first(), topic=topic, created=timestamp_to_datetime(pbb_reply["created"]) ) print "Migrating Reply %s by %s" % (reply.content, reply.author.username) db.session.add(reply) db.session.commit() with app.app_context(): db.drop_all() db.create_all() main()