read binary files with b flag on import
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2712 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
878e18d244
commit
4829cc7b6f
1 changed files with 4 additions and 2 deletions
6
external/element.py
vendored
6
external/element.py
vendored
|
@ -143,9 +143,11 @@ class ResourceElement(Element):
|
|||
if k not in self.posArgs)
|
||||
dataPath = os.path.join(loader.resourceDirectory, self['name'])
|
||||
if os.path.exists(dataPath):
|
||||
f = open(dataPath, 'r')
|
||||
ct = self.get('contentType', '')
|
||||
flag = ct.startswith('text/') and 'r' or 'rb'
|
||||
f = open(dataPath, flag)
|
||||
content = f.read()
|
||||
if self.get('contentType', '').startswith('text/'):
|
||||
if ct.startswith('text/'):
|
||||
content = content.decode('UTF-8')
|
||||
kw['data'] = content
|
||||
f.close()
|
||||
|
|
Loading…
Add table
Reference in a new issue