MobileBlur

Changes On Branch 5a37a6a313c2bd25
Login

Changes On Branch 5a37a6a313c2bd25

Changes In Branch feature/web2py_auth Through [5a37a6a313] Excluding Merge-Ins

This is equivalent to a diff from b33aaf3ac3 to 5a37a6a313

2011-11-20
13:37
Merged in support for a real auth system, not a one-user DB kludge check-in: 57cc1847b3 user: spiffy tags: develop
05:28
Upgraded to web2py 1.99.2 check-in: 5e6e1e2c0a user: spiffy tags: feature/web2py_auth
05:13
Removed NewsBlur login tracking from the database and instead just give the client a copy of their NewsBlur cookie check-in: 5a37a6a313 user: spiffy tags: feature/web2py_auth
03:42
Merged in change from branch develop that fixes the app check-in: a162dcef14 user: spiffy tags: feature/web2py_auth
03:41
Removed web2py import calls from the Newsblur module check-in: b33aaf3ac3 user: spiffy tags: develop
03:12
Added a button to mark a feed as read check-in: b74e6c434b user: spiffy tags: develop

Modified applications/mobileblur/controllers/default.py from [f7fe7a35c9] to [b38b4efcae].

1
2
3
4
5
6
7
8
9
10
11
12
13















1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27











-

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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

    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)

Modified applications/mobileblur/models/0_helpers.py from [d9e34b5918] to [a3b08e626a].

1
2
3
4
5
6
7
8
9








1
2
3
4
5




6
7
8
9
10
11
12
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"]

Modified applications/mobileblur/models/db.py from [9c80a3439c] to [34c2cab0a7].

30
31
32
33
34
35
36

37
38
39
40
41
42
43
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44







+







## - crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

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
mail.settings.sender = 'you@gmail.com'         # your email
mail.settings.login = 'username:password'      # your credentials or None
82
83
84
85
86
87
88
89
83
84
85
86
87
88
89








-
#########################################################################

db.define_table("users",
    Field("username"),
    Field("password"),
    Field("cookie")
)
login()