changeset 118:267d1b2c2337

action.refresh: copied from MoinMoin.action and extended to delete tmp. cache files from arnica hint in CHANGES_arnica added
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 27 Jun 2008 12:26:44 +0200
parents eb46d3641b93
children 0dc7c254c5a8
files data/plugin/CHANGES_arnica data/plugin/action/refresh.py
diffstat 2 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/CHANGES_arnica	Fri Jun 27 10:38:10 2008 +0200
+++ b/data/plugin/CHANGES_arnica	Fri Jun 27 12:26:44 2008 +0200
@@ -8,6 +8,11 @@
          You have to remove them manually from the attachments dir. All attachments starting with "tmp." are ignored by arnica.
          There is also no migration script which renames Gallery2 to arnica on your pages. 
 
+ * HINT: The refresh action overwrites the one given from MoinMoin if it is added to the plugin dir of the wiki.
+         Using this action you can comfortable erase all thumb and webnails from the cache dir of the page and don't need 
+         to cycle the parser parameter renew from 0 to 1 and 0 back. The refresh action becomes disabled if arnica is invoked by
+         using the #format arnica statement. That's the reason because the renew parameter was not removed.
+
 arnica parser:
  * removed dependency to SWF library
  * caching is used for thumbnails and webnails
@@ -41,6 +46,9 @@
  * slide_show becomes a method
  * packLine/unpackLine used instead of join and split (separator is |)
 
+refresh action
+ * extends the MoinMoin refresh action to delete cache files of arnica
+   (arnicas cache files do start with tmp.)
 
 arnica macro
   * new (wrapper around the parser)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/action/refresh.py	Fri Jun 27 12:26:44 2008 +0200
@@ -0,0 +1,35 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - refresh cache of a page
+
+    @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
+                2006 MoinMoin:ThomasWaldmann
+                2008 MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+import os
+from MoinMoin import config
+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', ['Page.py'])[0]
+    if arena == 'Page.py':
+        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 
+    page = Page(request, pagename)
+    path = caching.get_arena_dir(request, page, 'item')
+    files = [fn.decode(config.charset) for fn in os.listdir(path)]
+    for key in files:
+        if key.startswith('tmp.'):
+            caching.CacheEntry(request, page, key, scope='item').remove()
+
+    request.page.send_page()