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:
helmutm 2008-06-17 09:53:43 +00:00
parent 878e18d244
commit 4829cc7b6f

6
external/element.py vendored
View file

@ -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()