[twill] managing sessions

Titus Brown titus at caltech.edu
Wed Dec 7 22:05:14 PST 2005


-> I don't think this has been covered explicitely yet (if I'm wrong about
-> that, I appologize), but I would like to know how to import twill into
-> another program and still be able to maintain sessions. I know that there is
-> a browser class which I believe manages the sessions (cookies and whatnot),
-> so I'm wondering if I should include my own instance of this browser class
-> into my program in order to accomplish this.
-> 
-> The scenerio is this:
-> I want to make a program that uses twill as the interface to http, and the
-> website is one which requires a login to access pages. I should only have to
-> log in once and then have twill manage the session data so I can still go to
-> any page on the site without being redirected back to a login page.
-> 
-> I want to import the twill commands and use them directly as function calls.
-> 
-> Is this possible? I may be confused on implimenting twill. I appologize if I
-> missed something basic.
-> 
-> Thanks.
-> 
-> Dave Erdman II

Hi, Dave,

it should "just work".  twill automatically sets up a cookie container
that manages site-specific information for you; you can use
load_cookies, save_cookies, and clear_cookies to interact with them.

If it *doesn't* just work, please let me know -- it may be that the site
isn't using cookies, or the cookies are broken, or...

To import the twill commands directly, you can just do

	from twill.commands import *

and then type 'go(url)' as you might expect.

cheers,
--titus



More information about the twill mailing list