Attachment 'Cachetest.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 Cachetest
4
5 this macro is used to find a problem of fuid
6
7 @copyright: 2009 MoinMoin:ReimarBauer
8
9 @license: GNU GPL, see COPYING for details.
10 """
11 from MoinMoin import caching, wikiutil
12 from MoinMoin.action import AttachFile, cache
13
14 def macro_Cachetest(macro, attachment=unicode):
15 request = macro.request
16 pagename = request.page.page_name
17
18 Image = wikiutil.importWikiPlugin(request.cfg, "macro", "Image", function="Image")
19 size = (128, 128)
20 cache_arena = 'sendcache'
21 cache_scope = 'wiki'
22 do_locking = False
23 if attachment and AttachFile.exists(request, pagename, attachment):
24 itemname = pagename + '/' + attachment
25 img = Image(request, itemname)
26 content_type = img.content_type
27 size_str = '%d_%d' % size
28 key = '%s_%s_%s' % (content_type.replace('/', '_'), size_str, img._cache_key)
29 meta_cache = caching.CacheEntry(request, cache_arena, key+'.meta', cache_scope, do_locking=do_locking, use_pickle=True)
30 result = """
31 IMG Cache key: %s <BR>
32 Key: %s <BR>
33 Cache exists: %s <BR>
34 Meta cache exists: %s <BR>
35 Needs Update: %s <BR>
36 """ % (img._cache_key, key, cache.exists(request, key), meta_cache.exists(), meta_cache.needsUpdate(img._filename))
37 return result
38
39 return "Attachment not found"
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.