예제 #1
0
def before_request():
    """Setup some common daos so we can use them across the board"""
    flask.g.connect = mongoengine.connect('blogizzle')
    flask.g.now = datetime.datetime.now()
    flask.g.post_count = len(Post.objects())
예제 #2
0
def read(slug):
    post = Post.objects(slug = slug)[0]
    return flask.render_template('post.html', post = post)
예제 #3
0
파일: test.py 프로젝트: elephant/Blogizzle
from blogizzle.Post import Post

from mongoengine import connect

connect('blogizzle', host='Hippo.local')

post = Post(title="Hello World!",
            body="Blah blah blah",
            ip="127.0.0.1")

try:
    post.save()
except:
    post._id = Post.objects(slug=post.slug).first()._id
    post.save()