Re: RE: Python 2.3 and aggregator
Jeremy Bowers <[email protected]> Wed, 21 Apr 2004 10:18:33 -0500
| Newsgroups | gmane.comp.pythin.pyds.devel |
|---|---|
| Message-ID | <[email protected]> |
Georg Bauer wrote:
> Hmm - what error do you get now? Still the stuff on None not having
> lower()? Or something different?
My apologies with regard to my code posting; I had thought that was the
code that worked but it actually does not. That was on another machine.
The open_http code in DownstreamTool that works for me (which I had to
reconstruct) is actually:
def open_http(self, url, data=None):
numheaders = len(self.addheaders)
self.isHTTP = 1
self.lastURL = self.getTheUrl(url)
try:
theurl = self.getTheUrl(url)
self.message = _('opening url: <a href="%s">%s</a>') % (theurl, theurl)
if not(self.force):
for h in self.cache._getUrlHeaders(theurl):
apply(self.addheader, h)
self.message += _('<br>adding Header "%s: %s"') % h
url = theurl[5:]
res = urllib.URLopener.open_http(self, url, data)
self.message = self.message.replace('%', '%%')
if self.verbose:
self.cache.logVerbose(self.message)
else:
self.cache.log(self.message)
return res
finally:
self.addheaders = self.addheaders[:numheaders]
Sorry about the wrapping, but note the "url = theurl[5:]" line;
open_http for some reason wants to see something like
'//slashdot.org/slashdot.rdf', not 'http://slashdot.org/slashdot.rdf'.
Passing in the host as ('slashdot.org',
'http://slashdot.org/slashdot.rdf') doesn't work, you get a 403.
This is working for me again now, and I'm back to my usual set of "time
out" errors for editthispage.com sites ;-)