~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/publication.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-07-22 05:56:29 UTC
  • mfrom: (13492.1.1 revert-r13485)
  • Revision ID: launchpad@pqm.canonical.com-20110722055629-0y8ss6zvhjcoo12r
[r=wgrant][rollback=13485] Revert r13485. It prevents form pickers
 from being attached to their text widgets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from zope.interface import providedBy
21
21
from zope.publisher.interfaces.browser import IDefaultSkin
22
22
from zope.security.management import restoreInteraction
23
 
from zope.security.proxy import removeSecurityProxy
24
23
 
25
24
from canonical.launchpad.interfaces.launchpad import IOpenLaunchBag
26
25
import canonical.launchpad.layers as layers
31
30
    )
32
31
from canonical.launchpad.webapp.servers import ProtocolErrorPublication
33
32
 
34
 
 
35
33
# Defines an helper function that returns the appropriate
36
34
# IRequest and IPublication.
37
35
def get_request_and_publication(host='localhost', port=None,
121
119
    getUtility(IOpenLaunchBag).clear()
122
120
    app = publication.getApplication(request)
123
121
    view = request.traverse(app)
124
 
    # Find the object from the view instead on relying that it stays
125
 
    # in the traversed_objects stack. That doesn't apply to the web
126
 
    # service for example.
127
 
    try:
128
 
        obj = removeSecurityProxy(view).context
129
 
    except AttributeError:
130
 
        # But sometime the view didn't store the context...
131
 
        # Use the last traversed object in these cases.
132
 
        obj = request.traversed_objects[-2]
 
122
    # Since the last traversed object is the view, the second last should be
 
123
    # the object that the view is on.
 
124
    obj = request.traversed_objects[-2]
133
125
 
134
126
    restoreInteraction()
135
127