Pete Taylor wrote:
> Hi all,
> this may be a dumb question, but after a lot of googling and looking
> around at paste.registry and such, I can't figure it out.  I found one
> spot on the pylons docs that gave a partial solution, but it was
> commented heavily saying "don't use this, as it turns out it's
> broken".  I tried it, because i'm like that, and they were right, it
> was broken.
> 
> I have an application that, as you might imagine, requires a bit of
> authentication.  This, however, forces me to, in my setUp method, run
> a (at this point fairly standardized) hook to my login page, login
> with a tester user, so that i can then proceed to actually test my
> controllers.
> 
> the issue is that, as you might imagine, my __before__ method checks
> for a user id in the session, and if not, redirects to login.  what i
> would like to do (i'm admitting my rails test background here) like to
> be able to explicitly set some attributes in the session from my test
> controller, beforehand, so that i don't have to actually post to the
> login page every time i want to test my controller.  certainly the
> user/client/roles structure would already have to have been created
> for the tests to actually work, but that's not a problem.  it's more
> the ability to set an attribute in the session *before* post.

I'm not sure how the session works, but the way I would do this is 
simply look in request.environ['REMOTE_USER'] in addition to the 
session, and use that value if available as the user_id.  You can pass a 
value in like app.get(..., extra_environ={'REMOTE_USER': 'bob}).  You 
can also pass extra_environ in to the TestApp constructor to have it set 
for all calls.



-- 
Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org
             : Write code, do good : http://topp.openplans.org/careers

_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users

Reply via email to