lp.testing.publication.test_traverse doesn't set the current participation

Bug #611570 reported by Michael Hudson-Doyle
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Low
Michael Hudson-Doyle

Bug Description

test_traverse's docstring claims that it "uses the currently logged in user" which is all well and good, but this means that it does not set up a new interaction, which in turn means that you will end up with a different request object being current as per get_current_browser_request than the one that's having .traverse() called on it. This can be very confusing.

I have a two line fix, but I'm not completely sure of it...

Related branches

Gary Poster (gary)
Changed in launchpad-foundations:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Gary Poster (gary) wrote :

From one perspective, a reasonable fix would be to do the following within test_traverse.

(before traversing)
from zope.security.management import endInteraction, newInteraction, restoreInteraction
endInteraction()
newInteraction(request)

(after traversing)
restoreInteraction()

We also could rip out the current participation (request) from the current interaction and replace it temporarily. This is a bit riskier; typically you want to make sure that the interaction (security policy instance) has the ability to clear any decision caches.

What did you have in mind?

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Re: [Bug 611570] Re: lp.testing.publication.test_traverse doesn't set the current participation

On Fri, 30 Jul 2010 21:57:41 -0000, Gary Poster <email address hidden> wrote:
> >From one perspective, a reasonable fix would be to do the following
> within test_traverse.
>
> (before traversing)
> from zope.security.management import endInteraction, newInteraction, restoreInteraction
> endInteraction()
> newInteraction(request)
>
> (after traversing)
> restoreInteraction()
>
> We also could rip out the current participation (request) from the
> current interaction and replace it temporarily. This is a bit riskier;
> typically you want to make sure that the interaction (security policy
> instance) has the ability to clear any decision caches.
>
> What did you have in mind?

I had something like the first solution you proposed in mind, although I
hadn't heard of restoreInteraction().

I got bogged down in trying to write tests for test_traverse though --
slightly scary stuff! And then my lucid install ate itself :(

Cheers,
mwh

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Gary, I think I have a fix in the attached branch. If you could have a look, that would be great. If you don't get to it, I'll add some more tests and comments and stuff tomorrow and propose it for review.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I found a few minutes to write some more tests, fix a few more bugs and propose the branch for merging.

Revision history for this message
Ursula Junque (ursinha) wrote : Bug fixed by a commit
tags: added: qa-needstesting
Ursula Junque (ursinha)
Changed in launchpad-foundations:
status: Triaged → Fix Committed
milestone: none → 10.08
assignee: nobody → Michael Hudson (mwhudson)
tags: added: qa-untestable
removed: qa-needstesting
Ursula Junque (ursinha)
tags: added: qa-ok
removed: qa-untestable
Changed in launchpad-foundations:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.