MobileBlur

Check-in [5a37a6a313]
Login
Overview
Comment:Removed NewsBlur login tracking from the database and instead just give the client a copy of their NewsBlur cookie
Timelines: family | ancestors | descendants | both | feature/web2py_auth
Files: files | file ages | folders
SHA1:5a37a6a313c2bd25d735a8e9eb35569cb84b9956
User & Date: spiffy on 2011-11-20 05:13:42
Other Links: manifest | tags
Context
2011-11-20
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

5
6
7
8
9
10
11
12
13















    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)






















<

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    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)

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

1
2
3
4
5
6
7
8
9




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"])









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

#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
..
82
83
84
85
86
87
88
89
## - 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
................................................................................
#########################################################################

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







>







 







<
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
..
83
84
85
86
87
88
89

## - 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
................................................................................
#########################################################################

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