urllib2 OpenerDirector question on usage.

Ant antroy at gmail.com
Wed Jun 21 08:29:02 EDT 2006


Hello all,

I am using urllib2 as a part of a web testing tool. One of the things I
am testing is the effect of two different people perforing the same
actions on the website - do they interfer with each other or not.

So to emulate this, I essentially have the following function:

def get_opener():
    policy = cookielib.DefaultCookiePolicy(rfc2965=True)
    cj = cookielib.CookieJar(policy)
    return urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

Now am I right in thinking that since I am creating a separate
CookieJar for each opener, then creating two openers and using one for
each hypothetical user will achieve this effect - i.e. sessions will be
separate from each other in the app, since the openers will return
different session cookies back to the server.

Cheers,

Ant...




More information about the Python-list mailing list