>On Sun, May 15, 2016 at 10:35:32PM +0000, Jelmer Vernooij wrote: > From: Jelmer Vernooij <[email protected]> > > --- > calypso/webdav.py | 16 +++++++++------- > calypso/xmlutils.py | 2 +- > 2 files changed, 10 insertions(+), 8 deletions(-) > > diff --git a/calypso/webdav.py b/calypso/webdav.py > index 4b52d67..d0e2a44 100644 > --- a/calypso/webdav.py > +++ b/calypso/webdav.py > @@ -57,11 +57,12 @@ def find_vobject_value(vobject, name): > return value > return None > > + > class Item(object): > > """Internal item. Wraps a vObject""" > > - def __init__(self, text, name=None, path=None): > + def __init__(self, text, name=None, path=None, parent_urlpath=None): > """Initialize object from ``text`` and different ``kwargs``.""" > > self.log = logging.getLogger(__name__) > @@ -105,6 +106,7 @@ class Item(object): > > self.path = path > self.name = self.object.x_calypso_name.value > + self.urlpath = "/".join([parent_urlpath, self.name]) > self.tag = self.object.name > self.etag = hashlib.sha1(text).hexdigest() > > @@ -254,7 +256,7 @@ class Collection(object): > > def read_file(self, path): > text = codecs.open(path,encoding='utf-8').read() > - item = Item(text, None, path) > + item = Item(text, None, path, self.urlpath) > return item > > def insert_file(self, path): > @@ -503,7 +505,7 @@ class Collection(object): > > self.log.debug('append name %s', name) > try: > - new_item = Item(text, name, None) > + new_item = Item(text, name, None, self.urlpath) > except Exception, e: > self.log.exception("Cannot create new item") > raise > @@ -530,7 +532,7 @@ class Collection(object): > path = old_item.path > > try: > - new_item = Item(text, name, path) > + new_item = Item(text, name, path, self.urlpath) > except Exception: > self.log.exception("Failed to replace %s", name) > raise > @@ -571,16 +573,16 @@ class Collection(object): > if ve.contents.has_key('dtstart') and > ve.contents.has_key('duration'): > del ve.contents['duration'] > new_ics.vevent_list = [ve] > - new_item = Item(new_ics.serialize().decode('utf-8'), > None, path) > + new_item = Item(new_ics.serialize().decode('utf-8'), > None, path, self.urlpath) > self.import_item(new_item, path) > else: > - new_item = Item(new_ics.serialize().decode('utf-8'), > None, path) > + new_item = Item(new_ics.serialize().decode('utf-8'), > None, path, self.urlpath) > self.import_item(new_item, path) > return True > except Exception, ex: > self.log.exception("Failed to import: %s", path) > return False > - > + > def write(self, headers=None, items=None): > return True > > diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py > index e01fcb0..d692b32 100644 > --- a/calypso/xmlutils.py > +++ b/calypso/xmlutils.py > @@ -146,7 +146,7 @@ def propfind(path, xml_request, collection, depth, > context): > multistatus.append(response) > > href = ET.Element(_tag("D", "href")) > - href.text = collection_name if is_collection else > "/".join([collection_name, item.name]) > + href.text = item.urlpath > response.append(href) > > propstat = ET.Element(_tag("D", "propstat")) > -- > 2.8.1
LGTM but having a testcase for these tings would be great. Cheers, -- Guido _______________________________________________ Calypso mailing list [email protected] http://keithp.com/mailman/listinfo/calypso
