Merge lp:~flacoste/launchpad/bug-559128 into lp:launchpad
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Gary Poster | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
Merged at revision: | not available | ||||||||
Proposed branch: | lp:~flacoste/launchpad/bug-559128 | ||||||||
Merge into: | lp:launchpad | ||||||||
Diff against target: |
452 lines (+121/-96) 10 files modified
lib/canonical/launchpad/scripts/__init__.py (+16/-18) lib/canonical/launchpad/webapp/interaction.py (+62/-1) lib/lp/bugs/scripts/checkwatches/updater.py (+3/-2) lib/lp/code/xmlrpc/codehosting.py (+4/-8) lib/lp/services/scripts/base.py (+3/-13) lib/lp/testing/__init__.py (+2/-1) lib/lp/testing/_login.py (+25/-38) lib/lp/testing/_webservice.py (+2/-1) scripts/bugzilla-import.py (+2/-7) scripts/sourceforge-import.py (+2/-7) |
||||||||
To merge this branch: | bzr merge lp:~flacoste/launchpad/bug-559128 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gary Poster (community) | Approve | ||
Review via email: mp+23504@code.launchpad.net |
Commit message
Don't import lp.testing in production code. Refactor login and login_person helper into setupInteractio
Description of the change
= Summary =
This branch should re-enable edge update (bug #559128) by fixing some tech-debt
(bug #285808)
The problem with the edge update is that subunit is now installed via a
package and that package isn't installed in production. You'd wonder why
subunit would be required for running Launchpad and that's exactly the point.
It turns out that some production code paths import from lp.testing because
they use the login and login_person helper (which was bug #285808).
== Proposed fix ==
Remove tech-debts
== Pre-implementation notes ==
Nothing special.
== Implementation details ==
I moved the useful part of login and login_person into two functions
setupInteractio
setupInteraction in canonical.
The login and login_person() contains the test-specific logic around these.
I updated all production call sites to use the one from
canonical.
Since execute_
only if the layers module has been imported. I would have removed it entirely,
but thought that the safety hook was worth the relative ugliness.
== Tests ==
This branch is a pure refactoring. I did test that lp.testing wasn't imported
anymore in production paths by adding a raise RuntimeError in lp.testing, it's
not trigger when calling make run. (It is before this fix.)
== Demo and Q/A ==
Nothing special
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files:
lib/canonical
lib/lp/
scripts/
lib/lp/
lib/lp/
lib/lp/
lib/canonical
scripts/
lib/lp/
lib/lp/
== Pyflakes notices ==
lib/lp/
8: 'getUtility' imported but unused
I fixed that one on a follow-up commit.
--
Francis J. Lacoste
<email address hidden>
Wow, very nice!
"Zopefull": nice word :-)
Very nice cleanups in the branch, such as correcting the imports from zope.security.
A niggle, but I found it a bit odd when ``setupInteract ionForPerson` ` called ``return setupInteractio nByEmail( ANONYMOUS, participation)``. I wondered why I should call a function with the word "email" in it to get an interaction when there's no email involved. My preference would be to change setupInteraction to look like this:
def setupInteractio n(principal, login=None, participation= None):
"""Sets up a new interaction with the given principal.
The login gets added to the launch bag.
You can optionally pass in a participation to be used. If no
endInteraction ()
participation is given, a Participation is used.
"""
# If principal is None, this method acts just like endInteraction.
if principal is None:
return
# THIS IS THE NEW BIT IPlacelessAuthU tility) unauthenticated Principal( )
if principal == ANONYMOUS:
authutil = getUtility(
principal = authutil.
if participation is None:
participation = Participation()
(... and so on, as is)
Then the line in `setupInteracti onForPerson` ` would read ``return setupInteractio n(ANONYMOUS) ``. That makes much more sense to me. I'd guess you'd also delete these lines from ``setupInteract ionByEmail` ` too, because they would be unnecessary:
119 + else: unauthenticated Principal( )
120 + principal = authutil.
As I said, that's a niggle, and I won't insist on it, but it did give me pause.
Looks like you caught all my XXXs. :-) Yay!
Thank you,
Gary