Index: applications/mobileblur/controllers/default.py ================================================================== --- applications/mobileblur/controllers/default.py +++ applications/mobileblur/controllers/default.py @@ -7,7 +7,21 @@ for i in range(threshold, 2): if feed[thresholds[i]] > 0: feeds[feed["feed_title"]] = feed break - pprint(feeds) 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) Index: applications/mobileblur/models/0_helpers.py ================================================================== --- applications/mobileblur/models/0_helpers.py +++ applications/mobileblur/models/0_helpers.py @@ -1,9 +1,13 @@ newsblur = local_import("newsblur") threshold = 0 thresholds = ["nt", "ps", "ng"] # indices -1, 0, 1 for negative, neutral, and positive intelligence filters -def login(username="spiffytech"): - user = db(db.users.username==username).select().first() - if user["cookie"] is None: - results = newsblur.login(user["username"], user["password"]) +#import ipdb +#ipdb.set_trace() +print request.env.path_info +if "nb_cookie" not in request.cookies.keys(): + if [request.application, request.controller, request.function] != [request.application, "default", "login"]: + redirect(URL("default", "login", vars=dict(redirect=request.folder))) +#else: +# newsblur.cookies = request.cookies["nb_cookie"] Index: applications/mobileblur/models/db.py ================================================================== --- applications/mobileblur/models/db.py +++ applications/mobileblur/models/db.py @@ -32,10 +32,11 @@ ######################################################################### from gluon.tools import Mail, Auth, Crud, Service, PluginManager, prettydate mail = Mail() # mailer auth = Auth(db) # authentication/authorization + crud = Crud(db) # for CRUD helpers using auth service = Service() # for json, xml, jsonrpc, xmlrpc, amfrpc plugins = PluginManager() # for configuring plugins mail.settings.server = 'logging' or 'smtp.gmail.com:587' # your SMTP server @@ -84,6 +85,5 @@ db.define_table("users", Field("username"), Field("password"), Field("cookie") ) -login()