cubicweb/web/propertysheet.py
branch3.23
changeset 11461 f5a4e14d1dd2
parent 11434 f6ba947c11ee
parent 11057 0b59724cb3f2
child 11767 432f87a63057
child 11961 a25e52cd8be4
--- a/cubicweb/web/propertysheet.py	Tue Aug 16 14:26:41 2016 +0200
+++ b/cubicweb/web/propertysheet.py	Thu Sep 08 11:40:50 2016 +0200
@@ -1,4 +1,4 @@
-# copyright 2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2010-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -29,10 +29,12 @@
                ('STYLESHEETS_IE', list), ('STYLESHEETS_PRINT', list),
                ]
 
+
 class lazystr(object):
     def __init__(self, string, context):
         self.string = string
         self.context = context
+
     def __str__(self):
         return self.string % self.context
 
@@ -105,7 +107,12 @@
             tmpfd, tmpfile = tempfile.mkstemp(dir=rcachedir, prefix=osp.basename(cachefile))
             with os.fdopen(tmpfd, 'w') as stream:
                 stream.write(content)
-            os.rename(tmpfile, cachefile)
+            try:
+                os.rename(tmpfile, cachefile)
+            except IOError:
+                # Under windows, os.rename won't overwrite an existing file
+                os.unlink(cachefile)
+                os.rename(tmpfile, cachefile)
             adirectory = self._cache_directory
         return adirectory