MobileBlur

default.py at [5a37a6a313]
Login

default.py at [5a37a6a313]

File applications/mobileblur/controllers/default.py artifact b38b4efcae part of check-in 5a37a6a313


from pprint import pprint

def index():
    raw_feeds = newsblur.feeds(flat=True)["feeds"]
    feeds = {}
    for feed in raw_feeds.itervalues():
        for i in range(threshold, 2):
            if feed[thresholds[i]] > 0:
                feeds[feed["feed_title"]] = feed
                break

    return dict(feeds=feeds, threshold=threshold)


def login():
    login_form = SQLFORM.factory(
        Field("username", requires=IS_NOT_EMPTY()),
        Field("password", "password", requires=IS_NOT_EMPTY())
    )
    if login_form.accepts(request):
        results = newsblur.login(login_form.vars["username"], login_form.vars["password"])
        response.cookies["nb_cookie"] = newsblur.cookies
        response.cookies["nb_cookie"]["path"] = "/"
        print "cookie =", newsblur.cookies
        redirect(URL("index"))

    return dict(login_form=login_form)