Disabling the AttachFile action

The AttachFile action lets a page have multiple attached files.

Since file uploads could be abused for DoS (Denial of Service) attacks, AttachFile is an action that can be disabled by the wiki administrator. See Configuration of MoinMoin for details.

Creating attachments

To create a new attachment, you can either add an attachment link to any page (see below on how to do that), or click on the AttachFile link at the bottom of the page. In the first case, you will see an Upload new attachment link after saving the page. Clicking on it will lead you to the upload page, just like directly clicking on the AttachFile link.

The upload form consist of two fields. In addition to the file input there is an optional field (Rename to), used to give the file a different name than on your own computer.

Existing attachments may be viewed, downloaded, or removed, depending on the configuration of the wiki and the access rights of the user. For example, an attachment cannot be deleted if the user doesn't have the delete permission on the particular page.

Any upload or deletion of attachments is reflected on RecentChanges and thus subject to peer review. Unlike page changes, there is no history though, so keep a local copy of files so you can revert possible vandalism.

Listing and information about attachments

Two macros are defined which give information about attachments on a page. The <<AttachInfo>> macro gives a short sentence about any attachments:

There are 8 attachment(s) stored for this page.

The <<AttachList>> macro lists files attached to a page:

--> -->

OSError

[Errno 2] No such file or directory: '/var/www/CAKE/wiki/underlay/pages/HelpOnActions(2f)AttachFile/attachments/unzip6b.png'

If you want to report a bug, please save this page and attach it to your bug report.

Traceback

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

  1. /usr/lib/python2.6/site-packages/MoinMoin/request/__init__.py in run (self=<MoinMoin.request.request_cgi.Request object at 0x23a9150>)

    1. 1309 self.page.send_page()
    2. 1310 else:
    3. 1311 handler(self.page.page_name, self)
    4. 1312
    5. 1313 # every action that didn't use to raise MoinMoinFinish must call this now:
    • handler = <function do_show at 0x243faa0>
    • self = <MoinMoin.request.request_cgi.Request object at 0x23a9150>
    • self.page = <MoinMoin.Page.Page object at 0x24ac550>
    • self.page.page_name = u'HelpOnActions/AttachFile'
  2. /usr/lib/python2.6/site-packages/MoinMoin/action/__init__.py in do_show (pagename=u'HelpOnActions/AttachFile', request=<MoinMoin.request.request_cgi.Request object at 0x23a9150>, content_only=0, count_hit=1, cacheable=1, print_mode=0)

    1. 251 count_hit=count_hit,
    2. 252 print_mode=print_mode,
    3. 253 content_only=content_only,
    4. 254 )
    5. 255
    • content_only = 0
  3. /usr/lib/python2.6/site-packages/MoinMoin/Page.py in send_page (self=<MoinMoin.Page.Page object at 0x24c8350>, **keywords={'content_only': 0, 'count_hit': 1, 'print_mode': 0})

    1. 1199 format_args=pi['formatargs'],
    2. 1200 do_cache=do_cache,
    3. 1201 start_line=pi['lines'])
    4. 1202
    5. 1203 # check for pending footnotes
    • start_line undefined
    • pi = {'acl': <MoinMoin.security.AccessControlList instance at 0x24aee18>, 'format': u'wiki', 'formatargs': u'', 'language': u'en', 'lines': 7}
  4. /usr/lib/python2.6/site-packages/MoinMoin/Page.py in send_page_content (self=<MoinMoin.Page.Page object at 0x24c8350>, request=<MoinMoin.request.request_cgi.Request object at 0x23a9150>, body=u'== Disabling the AttachFile action ==\n\nThe `Atta...e target page must be an already existing page).\n', format=u'wiki', format_args=u'', do_cache=1, **kw={'start_line': 7})

    1. 1287 try:
    2. 1288 code = self.loadCache(request)
    3. 1289 self.execute(request, parser, code)
    4. 1290 except Exception, e:
    5. 1291 if not is_cache_exception(e):
    • self = <MoinMoin.Page.Page object at 0x24c8350>
    • self.execute = <bound method Page.execute of <MoinMoin.Page.Page object at 0x24c8350>>
    • request = <MoinMoin.request.request_cgi.Request object at 0x23a9150>
    • parser = <MoinMoin.parser.text_moin_wiki.Parser instance at 0x24fd878>
    • code = <code object <module> at 0x2558d50, file "HelpOnActions/AttachFile", line 2>
  5. /usr/lib/python2.6/site-packages/MoinMoin/Page.py in execute (self=<MoinMoin.Page.Page object at 0x24c8350>, request=<MoinMoin.request.request_cgi.Request object at 0x23a9150>, parser=<MoinMoin.parser.text_moin_wiki.Parser instance at 0x24fd878>, code=<code object <module> at 0x2558d50, file "HelpOnActions/AttachFile", line 2>)

    1. 1318 __file__ = os.path.join(MoinMoin.__loader__.archive, 'dummy')
    2. 1319 try:
    3. 1320 exec code
    4. 1321 except "CacheNeedsUpdate": # convert the exception
    5. 1322 raise Exception("CacheNeedsUpdate")
    • code = <code object <module> at 0x2558d50, file "HelpOnActions/AttachFile", line 2>
  6. /var/www/CAKE/wiki/HelpOnActions/AttachFile in ()

  7. /usr/lib/python2.6/site-packages/MoinMoin/formatter/__init__.py in macro (self=<MoinMoin.formatter.text_html.Formatter instance at 0x24ae7e8>, macro_obj=<MoinMoin.macro.Macro instance at 0x24fd710>, name=u'AttachList', args=None, markup=u'<<AttachList>>')

    1. 308 # call the macro
    2. 309 try:
    3. 310 return macro_obj.execute(name, args)
    4. 311 except ImportError, err:
    5. 312 errmsg = unicode(err)
    • macro_obj = <MoinMoin.macro.Macro instance at 0x24fd710>
    • macro_obj.execute = <bound method Macro.execute of <MoinMoin.macro.Macro instance at 0x24fd710>>
    • name = u'AttachList'
    • args = None
  8. /usr/lib/python2.6/site-packages/MoinMoin/macro/__init__.py in execute (self=<MoinMoin.macro.Macro instance at 0x24fd710>, macro_name=u'AttachList', args=None)

    1. 127 else:
    2. 128 raise ImportError("Cannot load macro %s" % macro_name)
    3. 129 return execute(self, args)
    4. 130
    5. 131 def _m_lang(self, text):
    • execute = <function <lambda> at 0x7f7fa0f91140>
    • self = <MoinMoin.macro.Macro instance at 0x24fd710>
    • args = None
  9. /usr/lib/python2.6/site-packages/MoinMoin/macro/__init__.py in (_self=<MoinMoin.macro.Macro instance at 0x24fd710>, _args=None)

    1. 114 call = wikiutil.importPlugin(self.cfg, 'macro', macro_name,
    2. 115 function='macro_%s' % macro_name)
    3. 116 execute = lambda _self, _args: _self._wrap(call, _args, [self])
    4. 117 except wikiutil.PluginAttributeError:
    5. 118 # fall back to old execute() method, no longer recommended
    • execute undefined
    • _self = <MoinMoin.macro.Macro instance at 0x24fd710>
    • _args = None
    • _self._wrap = <bound method Macro._wrap of <MoinMoin.macro.Macro instance at 0x24fd710>>
    • call = <function macro_AttachList at 0x7f7fa0f91230>
    • self = <MoinMoin.macro.Macro instance at 0x24fd710>
  10. /usr/lib/python2.6/site-packages/MoinMoin/macro/__init__.py in _wrap (self=<MoinMoin.macro.Macro instance at 0x24fd710>, function=<function macro_AttachList at 0x7f7fa0f91230>, args=None, fixed=[<MoinMoin.macro.Macro instance at 0x24fd710>])

    1. 96 try:
    2. 97 return wikiutil.invoke_extension_function(self.request, function,
    3. 98 args, fixed)
    4. 99 except ValueError, e:
    5. 100 return self.format_error(e)
    • args = None
    • fixed = [<MoinMoin.macro.Macro instance at 0x24fd710>]
  11. /usr/lib/python2.6/site-packages/MoinMoin/wikiutil.py in invoke_extension_function (request=<MoinMoin.request.request_cgi.Request object at 0x23a9150>, function=<function macro_AttachList at 0x7f7fa0f91230>, args=None, fixed_args=[<MoinMoin.macro.Macro instance at 0x24fd710>])

    1. 1997 kwargs_to_pass.keys()[0]))
    2. 1998
    3. 1999 return function(*fixed_args, **kwargs)
    4. 2000
    5. 2001
    • function = <function macro_AttachList at 0x7f7fa0f91230>
    • fixed_args = [<MoinMoin.macro.Macro instance at 0x24fd710>]
    • kwargs = {'mime_type': u'*', 'pagename': None}
  12. /usr/lib/python2.6/site-packages/MoinMoin/macro/AttachList.py in macro_AttachList (macro=<MoinMoin.macro.Macro instance at 0x24fd710>, pagename=u'HelpOnActions/AttachFile', mime_type=u'*')

    1. 20 if not pagename:
    2. 21 pagename = macro.formatter.page.page_name
    3. 22
    4. 23 return _build_filelist(macro.request, pagename, 0, 1, mime_type=mime_type)
    5. 24
    • global _build_filelist = <function _build_filelist at 0x2475668>
    • macro = <MoinMoin.macro.Macro instance at 0x24fd710>
    • macro.request = <MoinMoin.request.request_cgi.Request object at 0x23a9150>
    • pagename = u'HelpOnActions/AttachFile'
    • mime_type = u'*'
  13. /usr/lib/python2.6/site-packages/MoinMoin/action/AttachFile.py in _build_filelist (request=<MoinMoin.request.request_cgi.Request object at 0x23a9150>, pagename=u'HelpOnActions/AttachFile', showheader=0, readonly=1, mime_type=u'*')

    1. 305 mt = wikiutil.MimeType(filename=file)
    2. 306 fullpath = os.path.join(attach_dir, file).encode(config.charset)
    3. 307 st = os.stat(fullpath)
    4. 308 base, ext = os.path.splitext(file)
    5. 309 parmdict = {'file': wikiutil.escape(file),
    • st = posix.stat_result(st_mode=33188, st_ino=70700, s...832109, st_mtime=1266113843, st_ctime=1273275219)
    • global os = <module 'os' from '/usr/lib64/python2.6/os.pyc'>
    • os.stat = <built-in function stat>
    • fullpath = '/var/www/CAKE/wiki/underlay/pages/HelpOnActions(2f)AttachFile/attachments/unzip6b.png'

OSError

[Errno 2] No such file or directory: '/var/www/CAKE/wiki/underlay/pages/HelpOnActions(2f)AttachFile/attachments/unzip6b.png'

  • args = (2, 'No such file or directory')
  • errno = 2
  • filename = '/var/www/CAKE/wiki/underlay/pages/HelpOnActions(2f)AttachFile/attachments/unzip6b.png'
  • message = ''
  • strerror = 'No such file or directory'

System Details

  • Date: Thu, 09 Sep 2010 03:37:33 +0000
  • Platform: Linux attic.omnifarious.org 2.6.32.12-115.fc12.x86_64 #1 SMP Fri Apr 30 19:46:25 UTC 2010 x86_64
  • Python: Python 2.6.2 (/usr/bin/python)
  • MoinMoin: Release 1.8.7 (release)