view MoinMoin/script/maint/cleancache.py @ 2881:e4a320fe298a

maint.cleancache: cleans now dicts_groups too (bug fix)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 27 Sep 2007 08:37:49 +0200
parents 01f05e74aa9c
children c0366b467edf
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - cleancache script

    globally delete cache files in data/pages/PageName/cache/ directories

    You will usually do this after changing MoinMoin code, by either upgrading
    version, installing or removing macros. This often makes the text_html
    files invalid, so you have to remove them (the wiki will recreate them
    automatically).

    text_html is the name of the cache file used for compiled pages formatted
    by the wiki text to html formatter,

    @copyright: 2005-2006 MoinMoin:ThomasWaldmann
                2007 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
"""

cachefiles_to_delete = ['text_html', 'pagelinks', ]

import os

from MoinMoin.script import MoinScript

class PluginScript(MoinScript):
    def __init__(self, argv, def_values):
        MoinScript.__init__(self, argv, def_values)

    def mainloop(self):
        self.init_request()
        base = self.request.cfg.data_dir
        pagesdir = os.path.join(base, 'pages')
        for f in os.listdir(pagesdir):
            for fname in cachefiles_to_delete:
                cachefile = os.path.join(pagesdir, f, 'cache', fname)
                try:
                    os.remove(cachefile)
                    print "Removed %s" % cachefile
                except:
                    pass

        # cleans the wikidicts
        cache_file = os.path.join(base, 'cache', 'wikiconfig', 'wikidicts', 'dicts_groups')
        try:
            os.remove(cache_file)
            print "Removed %s" % cache_file
        except:
            pass