Merge lp:~salgado/launchpad/bug-527921 into lp:launchpad

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: not available
Proposed branch: lp:~salgado/launchpad/bug-527921
Merge into: lp:launchpad
Diff against target: 35 lines (+11/-1)
1 file modified
lib/canonical/launchpad/webapp/login.py (+11/-1)
To merge this branch: bzr merge lp:~salgado/launchpad/bug-527921
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+20175@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

Use the master store in OpenIDCallbackView.render() to try and avoid
being fooled by a lagged slave.

Revision history for this message
Gary Poster (gary) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/webapp/login.py'
2--- lib/canonical/launchpad/webapp/login.py 2010-02-25 13:10:26 +0000
3+++ lib/canonical/launchpad/webapp/login.py 2010-02-25 20:38:15 +0000
4@@ -1,5 +1,6 @@
5 # Copyright 2009 Canonical Ltd. This software is licensed under the
6 # GNU Affero General Public License version 3 (see the file LICENSE).
7+from __future__ import with_statement
8
9 """Stuff to do with logging in and logging out."""
10
11@@ -34,6 +35,7 @@
12 from canonical.launchpad.interfaces.openidconsumer import IOpenIDConsumerStore
13 from lp.registry.interfaces.person import IPerson, PersonCreationRationale
14 from canonical.launchpad.readonly import is_read_only
15+from canonical.launchpad.webapp.dbpolicy import MasterDatabasePolicy
16 from canonical.launchpad.webapp.error import SystemErrorView
17 from canonical.launchpad.webapp.interfaces import (
18 CookieAuthLoggedInEvent, ILaunchpadApplication, ILaunchpadPrincipal,
19@@ -290,7 +292,15 @@
20
21 if account.status == AccountStatus.SUSPENDED:
22 return self.suspended_account_template()
23- if IPerson(account, None) is None:
24+ # XXX: salgado, 2010-02-15, bug=527921: Force the use of the
25+ # master database to make sure a lagged slave doesn't fool us into
26+ # creating a Person when one already exists. This was done without
27+ # proof that it will fix the bug, but if it works we may decide to
28+ # move it to lp.registry.model.person.person_from_account() or
29+ # just catch the error raised by createPerson() and move on.
30+ with MasterDatabasePolicy():
31+ person = IPerson(account, None)
32+ if person is None:
33 removeSecurityProxy(account).createPerson(
34 PersonCreationRationale.OWNER_CREATED_LAUNCHPAD)
35 self.login(account)