equal
deleted
inserted
replaced
80 self._cw.set_header('last-modified', generateDateTime(os.stat(path).st_mtime)) |
80 self._cw.set_header('last-modified', generateDateTime(os.stat(path).st_mtime)) |
81 self._cw.validate_cache() |
81 self._cw.validate_cache() |
82 # XXX elif uri.startswith('/https/'): uri = uri[6:] |
82 # XXX elif uri.startswith('/https/'): uri = uri[6:] |
83 mimetype, encoding = mimetypes.guess_type(path) |
83 mimetype, encoding = mimetypes.guess_type(path) |
84 self._cw.set_content_type(mimetype, osp.basename(path), encoding) |
84 self._cw.set_content_type(mimetype, osp.basename(path), encoding) |
85 return file(path).read() |
85 with open(path, 'rb') as resource: |
|
86 return resource.read() |
86 |
87 |
87 @property |
88 @property |
88 def relpath(self): |
89 def relpath(self): |
89 """path of a requested file relative to the controller""" |
90 """path of a requested file relative to the controller""" |
90 path = self._cw.form.get('static_relative_path') |
91 path = self._cw.form.get('static_relative_path') |
150 self.logger.error('concatenated data url error: %r file ' |
151 self.logger.error('concatenated data url error: %r file ' |
151 'does not exist', path) |
152 'does not exist', path) |
152 if self.config.debugmode: |
153 if self.config.debugmode: |
153 raise NotFound(path) |
154 raise NotFound(path) |
154 else: |
155 else: |
155 for line in open(osp.join(dirpath, rid)): |
156 with open(osp.join(dirpath, rid), 'rb') as source: |
156 f.write(line) |
157 for line in source: |
|
158 f.write(line) |
157 f.write('\n') |
159 f.write('\n') |
158 return filepath |
160 return filepath |
159 |
161 |
160 |
162 |
161 class DataController(StaticFileController): |
163 class DataController(StaticFileController): |