[web/views/staticcontrollers] restore windows compat
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 11 Apr 2012 12:18:33 +0200
changeset 8361 7f356ba4181c
parent 8357 8b16593abd85
child 8362 4ac28926cd15
[web/views/staticcontrollers] restore windows compat
web/views/staticcontrollers.py
--- 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