Attachment 'Fuid.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 Fuid
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.action import AttachFile
12 from MoinMoin.util import filesys
13 from MoinMoin.support.python_compatibility import hmac_new
14
15 def macro_Fuid(macro, attachment=unicode):
16 request = macro.request
17 pagename = request.page.page_name
18 if attachment and AttachFile.exists(request, pagename, attachment):
19 secret = request.cfg.secrets['action/cache']
20 wikiname = request.cfg.interwikiname or request.cfg.siteid
21
22 fuid = filesys.fuid(AttachFile.getFilename(request, pagename, attachment))
23
24 hmac_data = u''.join([wikiname, pagename, attachment, repr(fuid)])
25 hmac_data = hmac_data.encode('utf-8')
26 key = hmac_new(secret, hmac_data).hexdigest()
27 result= []
28 fuid_str = """
29 fuid:<br>
30 st_mtime: %d
31 st_ino: %d
32 st_size: %d
33 fake_mtime: %d
34 """ % fuid
35 result.append(fuid_str)
36 result.append("key: %s<br>" % key)
37
38 return '<br>'.join(result)
39
40 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.