Rev 49: Implements list_dir. This should be enough to be pack-compliant in http://bazaar.launchpad.net/%7Ebzr/bzr.webdav/webdav
Vincent Ladeuil
v.ladeuil+lp at free.fr
Sun Jun 8 11:44:01 BST 2008
At http://bazaar.launchpad.net/%7Ebzr/bzr.webdav/webdav
------------------------------------------------------------
revno: 49
revision-id: v.ladeuil+lp at free.fr-20080608104358-0n80zg1lz9lbth51
parent: v.ladeuil+lp at free.fr-20080608085045-ic1og61059r0w44m
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: webdav
timestamp: Sun 2008-06-08 12:43:58 +0200
message:
Implements list_dir. This should be enough to be pack-compliant
but the test suite now requires stat() :-/
* webdav.py:
(_extract_dir_content): Downcast to str since the test suite
requires it.
(HttpDavTransport.listable): Yes we are.
(HttpDavTransport.list_dir): Plug the extraction.
modified:
test_webdav.py test_webdav.py-20060823130244-qvg4wqdodnmf5nhs-1
webdav.py webdav.py-20060816232542-enpjxth2743ttqpq-3
-------------- next part --------------
=== modified file 'test_webdav.py'
--- a/test_webdav.py 2008-06-08 08:50:45 +0000
+++ b/test_webdav.py 2008-06-08 10:43:58 +0000
@@ -422,7 +422,7 @@
class TestDavSaxParser(tests.TestCase):
- def test_apache2_example(self):
+ def test_list_dir_apache2_example(self):
example = """<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="DAV:">
<D:response>
@@ -462,7 +462,7 @@
webdav._extract_dir_content('http://localhost/blah',
StringIO(example)))
- def test_lighttpd_example(self):
+ def test_list_dir_lighttpd_example(self):
example = """<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
<D:response>
@@ -479,7 +479,7 @@
webdav._extract_dir_content('http://localhost/blah',
StringIO(example)))
- def test_malformed_response(self):
+ def test_list_dir_malformed_response(self):
# Invalid xml, neither multistatus nor response are properly closed
example = """<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
@@ -496,7 +496,7 @@
webdav._extract_dir_content,
'http://localhost/blah', StringIO(example))
- def test_incomplete_format_response(self):
+ def test_list_dir_incomplete_format_response(self):
# The minimal information is present but doesn't conform to RFC 2518
# (well, as I understand it since the reference servers disagree on
# more than details).
=== modified file 'webdav.py'
--- a/webdav.py 2008-06-08 08:50:45 +0000
+++ b/webdav.py 2008-06-08 10:43:58 +0000
@@ -93,6 +93,7 @@
osutils,
trace,
transport,
+ urlutils,
)
from bzrlib.transport.http import (
_urllib,
@@ -194,7 +195,9 @@
except xml.sax.SAXParseException, e:
raise errors.InvalidHttpResponse(
url, msg='Malformed xml response: %s' % e)
- return handler.get_dir_content()
+ # We receive already url-encoded strings so down-casting is safe. And bzr
+ # insists on getting strings not unicode strings.
+ return map(str, handler.get_dir_content())
class PUTRequest(_urllib2_wrappers.Request):
@@ -589,7 +592,7 @@
def listable(self):
"""See Transport.listable."""
- return False
+ return True
def list_dir(self, relpath):
"""
@@ -598,14 +601,13 @@
abspath = self._remote_path(relpath)
propfind = """<?xml version="1.0" encoding="utf-8" ?>
<D:propfind xmlns:D="DAV:">
- <D:prop/>
+ <D:allprop/>
</D:propfind>
"""
request = _urllib2_wrappers.Request('PROPFIND', abspath, propfind,
{'Depth': 1},
accepted_errors=[207, 404, 409,])
response = self._perform(request)
- data = response.read()
code = response.code
if code == 404:
@@ -621,8 +623,7 @@
# overwrite.
self._raise_http_error(abspath, response,
'unable to list %r directory' % (abspath))
- # FIXME: Yes, we need to plug the xml parser/handler here
- return []
+ return _extract_dir_content(abspath, response)
def lock_write(self, relpath):
"""Lock the given file for exclusive access.
More information about the bazaar-commits
mailing list