On Jul 13, 8:16 am, Alberto Valverde <[EMAIL PROTECTED]> wrote:
> JustinTullosswrote:
> > (....)
> > In addition,
> > it's very difficult to inspect the object that an SOP refers to since
> > it obfuscates the object's __dict__.
>
> This trick can help:
> req = pylons.request._current_obj() # get current request object wrapped
> by SOP
> print dir(req)
Thanks.
I found what I was really looking for in the code for setting up the
test app when you execute "paster shell". I adapted it for the my
TestController as follows:
class TestController(TestCase):
def __init__(self):
self.app = paste.fixture.TestApp(wsgiapp)
# Query the test app to setup the environment
tresponse = self.app.get('/_test_vars')
request_id = int(tresponse.body)
# Disable restoration during test_app requests
self.app.pre_request_hook = lambda self: \
paste.registry.restorer.restoration_end()
self.app.post_request_hook = lambda self: \
paste.registry.restorer.restoration_begin(request_id)
self.request_id = request_id
def setUp(self):
paste.registry.restorer.restoration_begin(self.request_id)
def tearDown(self):
paste.registry.restorer.restoration_end()
This allows you to access the pylons globals outside of your self.app
requests. You can inspect them and put things in there to your heart's
content. Be careful though, the SOPs won't get cleared between
consecutive requests in the same test.
Justin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---