[twill] managing sessions

Titus Brown titus at caltech.edu
Wed Dec 7 22:06:39 PST 2005

-> I'm doing something similar, though between runs rather than within the
-> same execution path.  The trick is to save and restore the cookies.
-> As a result of asking twill to go to a page, it has a cache of cookies
-> that the page may have provided.  These may be authentication or session
-> cookies, assuming the site uses them.  If the cookies are saved using
-> twill's command for it, then they can be restored in another run (or
-> function call) as if no time had passed.
-> So you could either manipulate the cookies, or you could, as you
-> suggest, instantiate the browser class (mechanize) that twill uses.
-> I'm sure Titus could explain better.  ;-)

Heck, no ;).

The only thing to add is that mechanize *allows* you to handle cookies;
twill *configures* mechanize to use cookies.  So you'd have to look at
twill/browser.py to see how to configure mechanize properly for this
purpose if you were going to use it directly.


More information about the twill mailing list