view data/plugin/action/ @ 171:6c5af220a85a

action.refresh: refactored for using of cache.remove
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 14 Jul 2008 19:36:57 +0200
parents 267d1b2c2337
children a399665b4cb9
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - refresh cache of a page

    @copyright: 2000-2004 Juergen Hermann <>,
                2006 MoinMoin:ThomasWaldmann
                2008 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
import os
from MoinMoin import config
from MoinMoin.action import cache
from MoinMoin.Page import Page

def execute(pagename, request):
    """ Handle refresh action """
    # Without arguments, refresh action will refresh the page text_html cache.
    arena = request.form.get('arena', [''])[0]
    if arena == '':
        arena = Page(request, pagename)
    key = request.form.get('key', ['text_html'])[0]

    # Remove cache entry (if exists), and send the page
    from MoinMoin import caching
    caching.CacheEntry(request, arena, key, scope='item').remove()
    caching.CacheEntry(request, arena, "pagelinks", scope='item').remove()

    # remove cache files from arnica 
    path = caching.CacheEntry(request, cache.cache_arena, "", 
                              cache.cache_scope, do_locking=False)._filename()
    files = [fn.decode(config.charset) for fn in os.listdir(path)  if fn.endswith('data')]
    for file_name in files:
        key, ext = os.path.splitext(file_name)
        if key.startswith('T') or key.startswith('W'):
            cache.remove(request, key)