[twill] Extending Twill Question
cargol at cs.washington.edu
Fri May 26 16:01:38 PDT 2006
I'm pretty new to twill and python in general (installing both just
yesterday :)) and was looking to see how I might add a couple new
functions for personal use or if anyone was interested (I am not very
clear on how the licensing works.) but need a bit of help getting started.
The first function is just forward, it looks like beyond adding
functions in commands.py and browser.py, the real changes would have to
be made in _mechanize.py since the History class doesn't seem to have
any support for going forward. It also doesn't seem to know what the
current page is which makes things a bit more difficult. I think I need
to store the current page in the History class, and then make some kind
of modifications in _mech_open, and to the functions defined in the
history class. Is this the right direction for doing this, or am I
missing something else?
Second, I would like to be able to follow a link by its number printed
out after using showlinks.
I added to commands.py:
>> follow <link#>
Visit the page at position link# in the list returned by showlinks.
and to browser.py:
def follow_link_num(self, linknum):
Follow the link by its number on the page.
links = self._browser.links()
linknum = int(linknum)
self._journey('follow_link', links[linknum - 1])
print>>OUT, '==> at', self.get_url()
This seems to work right now, but I'm afraid there's something I am
missing, or some error case that I'm not considering.
Anyways, very cool experience so far.
More information about the twill