From e929a3154e808f05b99b0e7abf42ac2d77eec88f Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 19 Oct 2015 09:31:34 +0200 Subject: [PATCH] avoid UnicodeEncodeError when object name contains special characters --- README.txt | 6 +++--- base.py | 6 +++++- helpers.txt | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.txt b/README.txt index 4068bfd..28fd4f3 100755 --- a/README.txt +++ b/README.txt @@ -50,7 +50,7 @@ top-level loops container and a concept manager: >>> cc1.title u'' >>> loopsRoot.getLoopsUri(cc1) - '.loops/concepts/cc1' + u'.loops/concepts/cc1' >>> cc2 = Concept(u'Zope 3') >>> concepts['cc2'] = cc2 @@ -154,7 +154,7 @@ also the relationship to the context object using a combination of URIs to item and the predicate of the relationship: >>> [c.token for c in children] - ['.loops/concepts/cc2:.loops/concepts/standard'] + [u'.loops/concepts/cc2:.loops/concepts/standard'] There is also a concept configuration view that allows updating the underlying context object: @@ -500,7 +500,7 @@ view; these views we have to provide as multi-adapters: [u'd001.txt', u'd002.txt', u'd003.txt', u'doc1', u'm1.m11.m111'] >>> view.target.title, view.target.token - ('New Resource', '.loops/resources/m1.m11.m111') + ('New Resource', u'.loops/resources/m1.m11.m111') A node object provides the targetSchema of its target: diff --git a/base.py b/base.py index c401bb1..23ff403 100644 --- a/base.py +++ b/base.py @@ -75,7 +75,11 @@ class Loops(Folder): return self.get('records') def getLoopsUri(self, obj): - return str(loopsPrefix + getPath(obj)[len(getPath(self)):]) + #return str(loopsPrefix + getPath(obj)[len(getPath(self)):]) + uri = loopsPrefix + getPath(obj)[len(getPath(self)):] + #if isinstance(uri, unicode): + # uri = uri.encode('UTF-8') + return uri def loopsTraverse(self, uri): prefix = loopsPrefix + '/' diff --git a/helpers.txt b/helpers.txt index 27edd4d..fd72818 100755 --- a/helpers.txt +++ b/helpers.txt @@ -109,7 +109,7 @@ So let's check the type of the type object: >>> type_type.title u'Type' >>> type_type.token - '.loops/concepts/type' + u'.loops/concepts/type' >>> type_type.tokenForSearch 'loops:concept:type' >>> type_type.qualifiers @@ -149,7 +149,7 @@ Now let's have a look at resources. >>> file1_type.title u'File' >>> file1_type.token - '.loops/concepts/file' + u'.loops/concepts/file' >>> file1_type.tokenForSearch 'loops:resource:file' >>> file1_type.qualifiers @@ -181,7 +181,7 @@ Now let's have a look at resources. >>> img1_type = IType(img1) >>> img1_type.token - '.loops/concepts/file' + u'.loops/concepts/file' >>> img1_type.tokenForSearch 'loops:resource:file' >>> img1_type.title