Monotone-Parent: f0967567767bc3e201a892b9a9fc17de9c47f0a1

Monotone-Revision: 223a4ad09a33c8b2083c58b7e512c78200d305ec

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2009-08-06T19:21:10
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2009-08-06 19:21:10 +00:00
parent 7895f290c9
commit dbc6bd1a8c
2 changed files with 37 additions and 10 deletions

View File

@ -1,3 +1,10 @@
2009-08-06 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Tests/webdavlib.py (WebDAVClient._prepare_headers): we don't set
the "content-length" header if the body is None.
(HTTPSimpleQuery.render): method must take a "self" parameter.
(WebDAVCalendarMultiget.__init__): added transaction class.
2009-08-06 Francis Lachapelle <flachapelle@inverse.ca>
* UI/PreferencesUI/UIxPreferences.m ([UIxPreferences

View File

@ -18,8 +18,9 @@ class WebDAVClient:
def _prepare_headers(self, query, body):
headers = { "User-Agent": "Mozilla/5.0",
"content-length": len(body),
"authorization": "Basic %s" % self.simpleauth_hash }
if body is not None:
headers["content-length"] = len(body)
if query.__dict__.has_key("query") and query.depth is not None:
headers["depth"] = query.depth
if query.__dict__.has_key("content_type"):
@ -45,17 +46,9 @@ class HTTPSimpleQuery:
self.start = -1
self.duration = -1
def render():
def render(self):
return None
class HTTPGET(HTTPSimpleQuery):
method = "GET"
class HTTPQuery(HTTPSimpleQuery):
def __init__(self, url, content_type):
HTTPSimpleQuery.__init__(self, url)
self.content_type = content_type
def set_response(self, http_response):
headers = {}
for rk, rv in http_response.getheaders():
@ -66,6 +59,14 @@ class HTTPQuery(HTTPSimpleQuery):
"version": http_response.version,
"body": http_response.read() }
class HTTPGET(HTTPSimpleQuery):
method = "GET"
class HTTPQuery(HTTPSimpleQuery):
def __init__(self, url, content_type):
HTTPSimpleQuery.__init__(self, url)
self.content_type = content_type
class HTTPPUT(HTTPQuery):
method = "PUT"
@ -76,6 +77,9 @@ class HTTPPUT(HTTPQuery):
def render(self):
return self.content
class HTTPPOST(HTTPPUT):
method = "POST"
class WebDAVQuery(HTTPQuery):
method = None
@ -138,6 +142,22 @@ class WebDAVPROPFIND(WebDAVQuery):
prop_tag = self.render_tag(prop)
props.append(_WD_XMLTreeElement(prop_tag))
class WebDAVCalendarMultiget(WebDAVREPORT):
def __init__(self, url, properties, hrefs):
WebDAVQuery.__init__(self, url)
multiget_tag = self.ns_mgr.register("calendar-multiget", "urn:ietf:params:xml:ns:caldav")
self.top_node = _WD_XMLTreeElement(multiget_tag)
props = _WD_XMLTreeElement("prop")
self.top_node.append(props)
for prop in properties:
prop_tag = self.render_tag(prop)
props.append(_WD_XMLTreeElement(prop_tag))
for href in hrefs:
href_node = _WD_XMLTreeElement("href")
self.top_node.append(href_node)
href_node.append(_WD_XMLTreeTextNode(href))
class WebDAVSyncQuery(WebDAVREPORT):
def __init__(self, url, token, properties):
WebDAVQuery.__init__(self, url)