avoid UnicodeEncodeError when object name contains special characters
This commit is contained in:
parent
57588f1e19
commit
e929a3154e
3 changed files with 11 additions and 7 deletions
|
@ -50,7 +50,7 @@ top-level loops container and a concept manager:
|
||||||
>>> cc1.title
|
>>> cc1.title
|
||||||
u''
|
u''
|
||||||
>>> loopsRoot.getLoopsUri(cc1)
|
>>> loopsRoot.getLoopsUri(cc1)
|
||||||
'.loops/concepts/cc1'
|
u'.loops/concepts/cc1'
|
||||||
|
|
||||||
>>> cc2 = Concept(u'Zope 3')
|
>>> cc2 = Concept(u'Zope 3')
|
||||||
>>> concepts['cc2'] = cc2
|
>>> 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:
|
of URIs to item and the predicate of the relationship:
|
||||||
|
|
||||||
>>> [c.token for c in children]
|
>>> [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
|
There is also a concept configuration view that allows updating the
|
||||||
underlying context object:
|
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']
|
[u'd001.txt', u'd002.txt', u'd003.txt', u'doc1', u'm1.m11.m111']
|
||||||
|
|
||||||
>>> view.target.title, view.target.token
|
>>> 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:
|
A node object provides the targetSchema of its target:
|
||||||
|
|
||||||
|
|
6
base.py
6
base.py
|
@ -75,7 +75,11 @@ class Loops(Folder):
|
||||||
return self.get('records')
|
return self.get('records')
|
||||||
|
|
||||||
def getLoopsUri(self, obj):
|
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):
|
def loopsTraverse(self, uri):
|
||||||
prefix = loopsPrefix + '/'
|
prefix = loopsPrefix + '/'
|
||||||
|
|
|
@ -109,7 +109,7 @@ So let's check the type of the type object:
|
||||||
>>> type_type.title
|
>>> type_type.title
|
||||||
u'Type'
|
u'Type'
|
||||||
>>> type_type.token
|
>>> type_type.token
|
||||||
'.loops/concepts/type'
|
u'.loops/concepts/type'
|
||||||
>>> type_type.tokenForSearch
|
>>> type_type.tokenForSearch
|
||||||
'loops:concept:type'
|
'loops:concept:type'
|
||||||
>>> type_type.qualifiers
|
>>> type_type.qualifiers
|
||||||
|
@ -149,7 +149,7 @@ Now let's have a look at resources.
|
||||||
>>> file1_type.title
|
>>> file1_type.title
|
||||||
u'File'
|
u'File'
|
||||||
>>> file1_type.token
|
>>> file1_type.token
|
||||||
'.loops/concepts/file'
|
u'.loops/concepts/file'
|
||||||
>>> file1_type.tokenForSearch
|
>>> file1_type.tokenForSearch
|
||||||
'loops:resource:file'
|
'loops:resource:file'
|
||||||
>>> file1_type.qualifiers
|
>>> file1_type.qualifiers
|
||||||
|
@ -181,7 +181,7 @@ Now let's have a look at resources.
|
||||||
|
|
||||||
>>> img1_type = IType(img1)
|
>>> img1_type = IType(img1)
|
||||||
>>> img1_type.token
|
>>> img1_type.token
|
||||||
'.loops/concepts/file'
|
u'.loops/concepts/file'
|
||||||
>>> img1_type.tokenForSearch
|
>>> img1_type.tokenForSearch
|
||||||
'loops:resource:file'
|
'loops:resource:file'
|
||||||
>>> img1_type.title
|
>>> img1_type.title
|
||||||
|
|
Loading…
Add table
Reference in a new issue