annotate MoinMoin/script/maint/cleancache.py @ 2940:d54b7635a9a7

refactor maint cleancache
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 05 Nov 2007 22:57:18 +0100
parents c0366b467edf
children 2572688e031a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
502
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
2 """
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
3 MoinMoin - cleancache script
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
4
2883
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
5 globally delete cache files in data/pages/PageName/cache/ and /data/cache directories
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
6
502
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
7 You will usually do this after changing MoinMoin code, by either upgrading
2883
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
8 version, installing or removing macros or changing the regex expression for dicts.
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
9 This often makes the text_html and dict files invalid, so you have to remove them
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
10 (the wiki will recreate them automatically).
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
11
502
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
12 text_html is the name of the cache file used for compiled pages formatted
2883
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
13 by the wiki text to html formatter, A dict file does cache the pages which
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
14 do fit to the page_group_regex variable.
502
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
15
2940
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
16 @copyright: 2005-2007 MoinMoin:ThomasWaldmann,
2881
e4a320fe298a maint.cleancache: cleans now dicts_groups too (bug fix)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2286
diff changeset
17 2007 MoinMoin:ReimarBauer
502
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
18 @license: GNU GPL, see COPYING for details.
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
19 """
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
20
2883
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
21 from MoinMoin import caching
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
22 from MoinMoin.Page import Page
670
687633456631 MoinMoin.script: move _util stuff to __init__
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 521
diff changeset
23 from MoinMoin.script import MoinScript
502
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
24
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
25 class PluginScript(MoinScript):
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
26 def __init__(self, argv, def_values):
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
27 MoinScript.__init__(self, argv, def_values)
929
da5623bc6819 script: whitespace only cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 670
diff changeset
28
502
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
29 def mainloop(self):
55691a4d867a moin maint cleancache
Thomas Waldmann <tw@waldmann-edv.de>
parents:
diff changeset
30 self.init_request()
2883
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
31 request = self.request
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
32
2940
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
33 # clean page scope cache entries
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
34 keys = ['text_html', 'pagelinks', ]
2883
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
35 pages = request.rootpage.getPageList(user='')
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
36 for pagename in pages:
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
37 arena = Page(request, pagename)
2940
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
38 for key in keys:
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
39 caching.CacheEntry(request, arena, key, scope='item').remove()
2883
c0366b467edf script.maint.cleancache: refactored uses now caching.CacheEntry(...).remove()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2881
diff changeset
40
2940
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
41 # clean wiki scope cache entries
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
42 arena_key_list = [
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
43 ('user', 'name2id'),
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
44 ('wikidicts', 'dicts_groups'),
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
45 ]
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
46 for arena, key in arena_key_list:
d54b7635a9a7 refactor maint cleancache
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2883
diff changeset
47 caching.CacheEntry(request, arena, key, scope='wiki').remove()
2881
e4a320fe298a maint.cleancache: cleans now dicts_groups too (bug fix)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2286
diff changeset
48