Merge lp:~davewalker/loco-team-portal/unauthed_lp_api into lp:loco-team-portal

Proposed by Dave Walker
Status: Merged
Merged at revision: not available
Proposed branch: lp:~davewalker/loco-team-portal/unauthed_lp_api
Merge into: lp:loco-team-portal
Diff against target: 44 lines (+6/-21)
1 file modified
loco_directory/common/launchpad.py (+6/-21)
To merge this branch: bzr merge lp:~davewalker/loco-team-portal/unauthed_lp_api
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Review via email: mp+17881@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Dave Walker (davewalker) wrote :
Revision history for this message
Daniel Holbach (dholbach) wrote :

Nice work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/common/launchpad.py'
2--- loco_directory/common/launchpad.py 2010-01-18 14:41:22 +0000
3+++ loco_directory/common/launchpad.py 2010-01-22 10:49:11 +0000
4@@ -1,7 +1,6 @@
5 # -*- coding: utf-8 -*-
6
7 from launchpadlib.launchpad import Launchpad
8-from launchpadlib.credentials import Credentials
9 from launchpadlib.errors import HTTPError
10 from launchpadlib.launchpad import EDGE_SERVICE_ROOT
11
12@@ -13,26 +12,12 @@
13
14 def lp_login(lp_instance=EDGE_SERVICE_ROOT):
15 cachedir = os.path.join(settings.PROJECT_PATH, 'lp_data/cache')
16- creddir = os.path.join(settings.PROJECT_PATH, 'lp_data/lp_credentials')
17- if not os.path.isdir(creddir):
18- os.makedirs(creddir)
19- cred = os.path.join(creddir, 'loco-directory.credentials')
20-
21- if os.path.exists(cred):
22- credentials = Credentials()
23- credentials.load(open(cred))
24- launchpad = Launchpad(credentials, lp_instance, cachedir)
25- else:
26- try:
27- launchpad = Launchpad.get_token_and_login('loco-directory',
28- lp_instance, cachedir)
29- except HTTPError, e:
30- print >> sys.stderr, 'Error connecting to Launchpad: %s' % str(e)
31- sys.exit(1)
32- f = open(cred, 'w')
33- os.chmod(cred, 0600)
34- launchpad.credentials.save(f)
35- f.close()
36+ client_ident = getattr(settings, 'LP_PROJECT_NAME', "LoCo Directory")
37+ try:
38+ launchpad = Launchpad.login_anonymously(client_ident, lp_instance, cachedir)
39+ except:
40+ # Support for launchpadlib pre 1.5.4.
41+ launchpad = Launchpad.login(client_ident, "", "", lp_instance, cachedir)
42 return launchpad
43
44 def is_user_on_loco_council(user):

Subscribers

People subscribed via source and target branches