[etwist] clear ui cache at server startup time. Closes #1806933
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 05 Jul 2011 12:09:53 +0200
changeset 7619 0d0344fd5231
parent 7618 5395007c415c
child 7620 bc2d690b97bf
[etwist] clear ui cache at server startup time. Closes #1806933 this avoid pb when cubicweb/cubes provide new version of some js/css and also accumulating junk in the cache directories
etwist/server.py
etwist/twctl.py
--- a/etwist/server.py	Tue Jul 05 10:54:52 2011 +0200
+++ b/etwist/server.py	Tue Jul 05 12:09:53 2011 +0200
@@ -174,7 +174,9 @@
     def __init__(self, config, paths):
         _, ext = osp.splitext(paths[0])
         self._resources = {}
-        # create a unique / predictable filename
+        # create a unique / predictable filename. We don't consider cubes
+        # version since uicache is cleared at server startup, and file's dates
+        # are checked in debug mode
         fname = 'cache_concat_' + hashlib.md5(';'.join(paths)).hexdigest() + ext
         filepath = osp.join(config.appdatahome, 'uicache', fname)
         LongTimeExpiringFile.__init__(self, config, filepath)
@@ -223,6 +225,7 @@
                     return False
         return True
 
+
 class CubicWebRootResource(resource.Resource):
     def __init__(self, config, vreg=None):
         resource.Resource.__init__(self)
--- a/etwist/twctl.py	Tue Jul 05 10:54:52 2011 +0200
+++ b/etwist/twctl.py	Tue Jul 05 12:09:53 2011 +0200
@@ -17,6 +17,10 @@
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-clt handlers for twisted"""
 
+from os.path import join
+
+from logilab.common.shellutils import rm
+
 from cubicweb.toolsutils import CommandHandler
 from cubicweb.web.webctl import WebCreateHandler
 
@@ -32,6 +36,9 @@
 
     def start_server(self, config):
         from cubicweb.etwist import server
+        config.info('clear ui caches')
+        for cachedir in ('uicache', 'uicachehttps'):
+            rm(join(config.appdatahome, cachedir, '*'))
         return server.run(config)
 
 class TWStopHandler(CommandHandler):