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.
  • [get | view] (2009-08-03 17:23:57, 1.3 KB) [[attachment:Cachetest.py]]
  • [get | view] (2009-08-03 12:34:28, 1.2 KB) [[attachment:Fuid.py]]
  • [get | view] (2011-11-29 04:14:28, 2428.0 KB) [[attachment:IMGP3941.JPG]]
  • [get | view] (2009-07-14 09:50:09, 22.6 KB) [[attachment:arnica-umlaut.jpg]]
  • [get | view] (2011-08-31 09:50:10, 6.9 KB) [[attachment:google-chrome-navigation-not-working.png]]
  • [get | view] (2009-01-21 22:16:17, 562.4 KB) [[attachment:result.zip]]
  • [get | view] (2009-01-23 17:35:55, 62.5 KB) [[attachment:result1.png]]
  • [get | view] (2009-01-23 17:35:50, 228.7 KB) [[attachment:result10.png]]
  • [get | view] (2012-02-11 20:51:16, 51.5 KB) [[attachment:result11.png]]
  • [get | view] (2012-02-11 20:52:49, 73.9 KB) [[attachment:result12.png]]
  • [get | view] (2009-01-21 22:17:08, 30.1 KB) [[attachment:result2.png]]
  • [get | view] (2009-01-23 17:35:59, 47.8 KB) [[attachment:result3.png]]
  • [get | view] (2009-01-23 17:36:04, 16.7 KB) [[attachment:result4.png]]
  • [get | view] (2009-01-23 17:36:09, 32.3 KB) [[attachment:result5.png]]
  • [get | view] (2009-01-23 17:36:14, 14.8 KB) [[attachment:result6.png]]
  • [get | view] (2009-01-23 17:36:18, 30.1 KB) [[attachment:result7.png]]
  • [get | view] (2009-01-23 17:36:24, 32.0 KB) [[attachment:result8.png]]
  • [get | view] (2009-01-23 17:36:30, 70.6 KB) [[attachment:result9.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.