Exemple #1
0
def getPostsForUser(username):
    connection = MongoClient()
    db = connection['donald']
    result = db.donald.find({'username':username})
    for post in result:
        post = transform.post(post)
    connection.close()
    return result
Exemple #2
0
def getPostsForUser(username):
    connection = MongoClient()
    db = connection['donald']
    result = db.donald.find({'username': username})
    for post in result:
        post = transform.post(post)
    connection.close()
    return result
Exemple #3
0
def getPost(username, slug):
    connection = MongoClient()
    db = connection ['blog']
    result = db.donald.find({"username":username, "slug": slug})
    connection.close()
    if result.count() == 0:
        return False
    else:
        return transform.post(result[0])
Exemple #4
0
def getPostsForUser(username):
    connection = MongoClient()
    db = connection['blog']
    result = db.donald.find({'username':username})
    connection.close()
    posts = []
    for post in result:
        posts.append(post)
    i = 0
    while(i < len(posts)):
        posts[i] = transform.post(posts[i])
        i+=1
    return posts
Exemple #5
0
def getAllPosts():
    connection = MongoClient()
    db = connection['blog']
    result = db.donald.find()
    connection.close()
    posts = []
    for post in result:
        posts.append(post)
    i = 0
    while(i < len(posts)):
        posts[i] = transform.post(posts[i])
        i+=1
    return posts
Exemple #6
0
def getPost(username, slug):
    con = sqlite3.connect("donald.db")
    cur=con.cursor()

    sql = "SELECT * FROM posts WHERE username = \"%s\" AND slug = \"%s\"" % (username, slug)
    post = cur.execute(sql).fetchone()

    if post:
        post = transform.post(post)
        con.close()
        return post
    else:
        con.close()
        return False
Exemple #7
0
def getPost(username, slug):
    con = sqlite3.connect("donald.db")
    cur = con.cursor()

    sql = "SELECT * FROM posts WHERE username = \"%s\" AND slug = \"%s\"" % (
        username, slug)
    post = cur.execute(sql).fetchone()

    if post:
        post = transform.post(post)
        con.close()
        return post
    else:
        con.close()
        return False