web/views/staticcontrollers.py
changeset 8361 7f356ba4181c
parent 8328 c53bbeea7870
child 8369 e538ad6f9b99
--- a/web/views/staticcontrollers.py	Tue Apr 10 21:52:23 2012 +0200
+++ b/web/views/staticcontrollers.py	Wed Apr 11 12:18:33 2012 +0200
@@ -82,7 +82,8 @@
         # XXX elif uri.startswith('/https/'): uri = uri[6:]
         mimetype, encoding = mimetypes.guess_type(path)
         self._cw.set_content_type(mimetype, osp.basename(path), encoding)
-        return file(path).read()
+        with open(path, 'rb') as resource:
+            return resource.read()
 
     @property
     def relpath(self):
@@ -152,8 +153,9 @@
                         if self.config.debugmode:
                             raise NotFound(path)
                     else:
-                        for line in open(osp.join(dirpath, rid)):
-                            f.write(line)
+                        with open(osp.join(dirpath, rid), 'rb') as source:
+                            for line in source:
+                                f.write(line)
                         f.write('\n')
         return filepath