<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Ok, but do I worry about fixing that by installing a newer mechanize<br>(or is that even possible without breaking twill?)<br>Or do I just accept errors like that as a fact of life?<br><br><div>&gt; Date: Sun, 4 Sep 2011 22:47:03 +0100<br>&gt; From: jjl@pobox.com<br>&gt; To: twill@lists.idyll.org<br>&gt; CC: spmcinerney@hotmail.com<br>&gt; Subject: Re: [twill] Using twill's builtin mechanize distribution throws AttributeError on _debug?<br>&gt; <br>&gt; That line hasn't been there in mechanize since 2008 -- back then it knew <br>&gt; much more about Python than it does now.  I'd guess that code worked with <br>&gt; versions of Python that had been released at that time.  Now it's based on <br>&gt; a fork of urllib2, so is less fragile to changes in Python.<br>&gt; <br>&gt; I guess neither of us (me nor Titus) spend much time on this stuff these <br>&gt; days.  Certainly mechanize is not dead but certainly resting pretty hard <br>&gt; -- but still, it's seen a fair amount of change since 2008.  Speaking for <br>&gt; myself more than Titus of course...<br>&gt; <br>&gt; <br>&gt; John<br>&gt; <br>&gt; On Sun, 4 Sep 2011, Stephen McInerney wrote:<br>&gt; <br>&gt; &gt;<br>&gt; &gt; Hi Titus,<br>&gt; &gt;<br>&gt; &gt; Can you look at that stacktrace though?<br>&gt; &gt; mechanize attempted to call robotparser._debug() which dos not exist (on this version anyway)<br>&gt; &gt; Is mechanize normally that flaky?<br>&gt; &gt; I guess I could kludge a dummy robotparser._debug(), but that seems bad.<br>&gt; &gt;<br>&gt; &gt; Thanks,<br>&gt; &gt; Stephen<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;&gt; Date: Sun, 4 Sep 2011 07:40:01 -0700<br>&gt; &gt;&gt; From: ctb@msu.edu<br>&gt; &gt;&gt; To: spmcinerney@hotmail.com<br>&gt; &gt;&gt; CC: twill@lists.idyll.org<br>&gt; &gt;&gt; Subject: Re: [twill] Using twill's builtin mechanize distribution throws        AttributeError on _debug?<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; Hi Stephen,<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; twill's built-in mechanize is rather old and out of date.  There should<br>&gt; &gt;&gt; be little or no internal state kept by twill itself; it's a really thin<br>&gt; &gt;&gt; wrapper around mechanize.  So you should be able to use it w/o any<br>&gt; &gt;&gt; problem.<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; cheers,<br>&gt; &gt;&gt; --titus<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; On Fri, Sep 02, 2011 at 12:45:38PM -0700, Stephen McInerney wrote:<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; twill experts,<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; I also posted this on StackOverflow, if you like to reply there:<br>&gt; &gt;&gt;&gt; http://stackoverflow.com/questions/7278103/using-twills-builtin-mechanize-distribution-throws-attributeerror-on-debug<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; Using twill's builtin mechanize distribution throws AttributeError on _debug?<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; I use twill (0.9) and I want to also access its builtin mechanize distribution (on Python 2.6.6).<br>&gt; &gt;&gt;&gt; I read all the documentation and I'm not clear whether they even support or recommend that, if so they certainly don't publicize it (you might like to document that).<br>&gt; &gt;&gt;&gt; It seems you can do:<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt;     import _mechanize_dist as mechanize<br>&gt; &gt;&gt;&gt;     br = mechanize.Browser()<br>&gt; &gt;&gt;&gt;     br.open('http://www.yahoo.com')<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; however mechanize throws the stupid AttributeError below on `robotparser._debug`. Should I not be trying to use it? or is it a 2.5/2.6 incompatibility?<br>&gt; &gt;&gt;&gt; (Twill itself works fine: `twill.commands.go('http://www.yahoo.com')`)<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt;     Traceback (most recent call last):<br>&gt; &gt;&gt;&gt;       File "&lt;pyshell#19&gt;", line 1, in &lt;module&gt;<br>&gt; &gt;&gt;&gt;         br.open('http://www.yahoo.com')<br>&gt; &gt;&gt;&gt;       File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_mechanize.py", line 212, in open<br>&gt; &gt;&gt;&gt;         return self._mech_open(url, data)<br>&gt; &gt;&gt;&gt;       File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_mechanize.py", line 238, in _mech_open<br>&gt; &gt;&gt;&gt;         response = UserAgentBase.open(self, request, data)<br>&gt; &gt;&gt;&gt;       File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_opener.py", line 175, in open<br>&gt; &gt;&gt;&gt;         req = meth(req)<br>&gt; &gt;&gt;&gt;       File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_http.py", line 440, in http_request<br>&gt; &gt;&gt;&gt;         self.rfp.read()<br>&gt; &gt;&gt;&gt;       File "C:\Dev\Python26\lib\site-packages\twill-0.9-py2.6.egg\twill\other_packages\_mechanize_dist\_http.py", line 387, in read<br>&gt; &gt;&gt;&gt;         robotparser._debug("parse lines")<br>&gt; &gt;&gt;&gt;     AttributeError: 'module' object has no attribute '_debug'<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; (Last question is: I'm not aware of any caveats about using both twill and mechanize commands side-by-side?)<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; Thanks,<br>&gt; &gt;&gt;&gt; Stephen<br>&gt; &gt;&gt;&gt;<br>&gt; &gt;&gt;&gt; _______________________________________________<br>&gt; &gt;&gt;&gt; twill mailing list<br>&gt; &gt;&gt;&gt; twill@lists.idyll.org<br>&gt; &gt;&gt;&gt; http://lists.idyll.org/listinfo/twill<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; --<br>&gt; &gt;&gt; C. Titus Brown, ctb@msu.edu<br>&gt; &gt;<br></div>                                               </div></body>
</html>