[MERGE] * Fix the test HTTPServer to be isolated from chdir calls made while it is running
Aaron Bentley
aaron at aaronbentley.com
Wed Feb 27 05:45:28 GMT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Collins wrote:
> Yay for ages spent scratching head. I can't believe this hasn't bitten
> someone yet.
bb:comment
> + * Fix the test HTTPServer to be isolated from chdir calls made while it is
> + running, allowing it to be used in blackbox tests. (Robert Collins)
> +
Good grief! This should never have been necessary.
> def _translate_path(self, path):
> - return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(
> - self, path)
> + """Translate a /-separated PATH to the local filename syntax.
At first glance, I wondered why you weren't using
urlutils.url_to_local_path.
Please clarify that we're translating http URLs, not file URLs, and that
the URL root location is the server's startup directory.
> + for word in words:
> + drive, word = os.path.splitdrive(word)
> + head, word = os.path.split(word)
> + if word in (os.curdir, os.pardir): continue
> + path = os.path.join(path, word)
> + return path
This looks odd. Is it really the right thing to look for a drive in
every component of the URL? Why are we splitting off head everywhere?
(I'm guessing this is all copy-paste code, but it still looks kinda wrong.)
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHxPj40F+nu1YWqI0RAvl5AJkB9F+zDKJ2a0OXCcl5XLzuEqO55QCeN8Me
NGY3nwif3mPGmD2dtFLyJnc=
=+0+S
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list