[Calypso-commits] [calypso] 02/02: Add a urlpath attribute rather than special casing in propfind().
Jelmer Vernooij
jelmer at moszumanska.debian.org
Sat May 21 18:11:03 UTC 2016
This is an automated email from the git hooks/post-receive script.
jelmer pushed a commit to branch master
in repository calypso.
commit 0b61aa7f1f3a71b1175463c79c231699cbdc3964
Author: Jelmer Vernooij <jelmer at jelmer.uk>
Date: Sun May 15 22:32:53 2016 +0000
Add a urlpath attribute rather than special casing in propfind().
---
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 4ffd15e..0267825 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -58,11 +58,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__)
@@ -106,6 +107,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()
@@ -259,7 +261,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):
@@ -508,7 +510,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
@@ -535,7 +537,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
@@ -576,16 +578,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"))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/calypso/calypso.git
More information about the Calypso-commits
mailing list