<HEAD></HEAD>
<BODY >
<P>Hi John,</P>
<P>thanks for answering. I digged a lot deeper now into the code... and I installed the latest mechanize code separately and tried it out. The latest mechanize version works correct, I can access the site easily with a simple script.</P>
<P>I did then something ugly ;-) - I copied the latest mechanize code over the mechanize code provided by twill to see if the bug is purely within mechanize. It still doesn't work with Twill, so I suggest that somehow the 2.4er tweaking (I use 2.4) from the side of twill is the cause.</P>
<P>I tried to figure out if the BasicAuth handler is called and came to the following code:</P>
<P>_opener.py (Lines 176 - 180): </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # In Python &gt;= 2.4, .open() supports processors already, so we must<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # call ._open() instead.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; urlopen = getattr(urllib2.OpenerDirector, "_open",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; urllib2.OpenerDirector.open)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response = urlopen(self, req, data)<BR></P>
<P>Here I'm lost... no idea why you copy most of the code of urllib2 and then reuse some portions of it... But i don't have the python source of urllib2 and I can't dig deeper. </P>
<P>What I found also interesting is that twill installs a own HTTPHandler (for whatever reason, I don't know what WSGI is...). Maybe this is the cause (_browser.py)?</P>
<P>def build_http_handler():<BR>&nbsp;&nbsp;&nbsp; from mechanize._urllib2 import HTTPHandler</P>
<P>&nbsp;&nbsp;&nbsp; class MyHTTPHandler(HTTPHandler):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def http_open(self, req):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.do_open(wsgi_intercept.WSGI_HTTPConnection, req)</P>
<P>&nbsp;&nbsp;&nbsp; return MyHTTPHandler</P>
<P>This will have to wait until next week since I'm leaving now the corporate environment.</P>
<P>Regards,</P>
<P>Andrew</P>
<P>&nbsp;&nbsp;&nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;On&nbsp;Fri,&nbsp;2&nbsp;Mar&nbsp;2007,&nbsp;subscriptions@smart-knowhow.de&nbsp;wrote:&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;[...]&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&gt;&nbsp;What&nbsp;I&nbsp;found&nbsp;seems&nbsp;to&nbsp;be&nbsp;curious:&nbsp;the&nbsp;password&nbsp;handler&nbsp;are&nbsp;coded&nbsp;in&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&gt;&nbsp;_auth.py&nbsp;within&nbsp;mechanize.&nbsp;If&nbsp;I&nbsp;put&nbsp;debug&nbsp;code&nbsp;in&nbsp;the&nbsp;"add_password"&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&gt;&nbsp;function&nbsp;of&nbsp;HTTPPasswordMgr&nbsp;then&nbsp;the&nbsp;corresponding&nbsp;code&nbsp;is&nbsp;executed&nbsp;if&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&gt;&nbsp;is&nbsp;issue&nbsp;a&nbsp;"add_auth"&nbsp;command.&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;They&nbsp;are&nbsp;forked&nbsp;because&nbsp;the&nbsp;urllib2&nbsp;code&nbsp;was&nbsp;buggy&nbsp;in&nbsp;2.4.&nbsp;&nbsp;I&nbsp;submitted&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;the&nbsp;fixes&nbsp;to&nbsp;SF,&nbsp;and&nbsp;they're&nbsp;there&nbsp;in&nbsp;Python&nbsp;2.5.&nbsp;&nbsp;Also,&nbsp;ISTR&nbsp;I&nbsp;added&nbsp;a&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;new&nbsp;proxy&nbsp;password&nbsp;manager&nbsp;to&nbsp;make&nbsp;the&nbsp;front-end&nbsp;proxy&nbsp;auth&nbsp;interface&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;friendlier&nbsp;(probably&nbsp;I&nbsp;should&nbsp;have&nbsp;written&nbsp;a&nbsp;new&nbsp;one&nbsp;from&nbsp;scratch&nbsp;rather&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;than&nbsp;derivint&nbsp;it&nbsp;from&nbsp;the&nbsp;urllib2&nbsp;code...).&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&gt;&nbsp;The&nbsp;corresponding&nbsp;find_user_password&nbsp;function&nbsp;is&nbsp;never&nbsp;called&nbsp;(at&nbsp;least&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&gt;&nbsp;in&nbsp;my&nbsp;case).&nbsp;I'm&nbsp;currently&nbsp;trying&nbsp;to&nbsp;figure&nbsp;out&nbsp;why...&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;That&nbsp;suggests&nbsp;you're&nbsp;not&nbsp;getting&nbsp;the&nbsp;expected&nbsp;401&nbsp;response&nbsp;from&nbsp;the&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;server.&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;Turn&nbsp;on&nbsp;logging&nbsp;of&nbsp;HTTP&nbsp;request&nbsp;and&nbsp;response&nbsp;headers&nbsp;--&nbsp;either&nbsp;in&nbsp;twill,&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;or&nbsp;using&nbsp;a&nbsp;simple&nbsp;mechanize&nbsp;script&nbsp;like&nbsp;the&nbsp;one&nbsp;I&nbsp;posted.&nbsp;&nbsp;To&nbsp;turn&nbsp;on&nbsp;the&nbsp;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;logging&nbsp;you&nbsp;need&nbsp;in&nbsp;mechanize:&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;import&nbsp;mechanize&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;hh&nbsp;=&nbsp;mechanize.HTTPHandler()&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;hsh&nbsp;=&nbsp;mechanize.HTTPHandler()&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;hh.set_http_debuglevel(1)&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;hsh.set_http_debuglevel(1)&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;opener&nbsp;=&nbsp;mechanize.build_opener(hh,&nbsp;hsh)&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;response&nbsp;=&nbsp;opener.open(url)&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;#&nbsp;etc.&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;John&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;_______________________________________________&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;twill&nbsp;mailing&nbsp;list&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;twill@lists.idyll.org&nbsp;&nbsp; &nbsp;</P>
<P style="MARGIN-TOP: 2px; MARGIN-BOTTOM: 2px">&gt;http://lists.idyll.org/listinfo/twill</P></BODY>