[Moin-user] MoinMoin 1.7.0 AttachFIle broken under mod_python 3.3.1?

Zhenlei Cai (Jerry) jpenguin at gmail.com
Sun Jul 20 06:10:12 EDT 2008


Once I upgrade to 1.7.0, attaching file always fail with a "I/O operation on
closed file"  error (stack attached at end). After tracing the code, I found
I am using mod_python 3.3.1. Its util.Field class will close the uploaded
temp file in its destructor.  Apparently MoinMoin save this file in its form
but since the original Field object has been garbage collected when Moin
later trys to copy the saved file the file has been closed and hence the
error.
Please confirm if this is a bug.



/usr/lib/python2.5/site-packages/MoinMoin/request/__init__.py in run
(self=<MoinMoin.request.request_modpython.Request object at 0x2aaabe10c950>)

 1318                          self.page.send_page()
 1319                      else:
 1320                          handler(self.page.page_name, self)
 1321
 1322              # every action that didn't use to raise MoinMoinFinish
must call this now:
handler = <function execute at 0x2aaabea905f0> self =
<MoinMoin.request.request_modpython.Request object at 0x2aaabe10c950>
self.page = <MoinMoin.Page.Page object at 0x2aaabea8f610>
self.page.page_name = u'MileStones'
/usr/lib/python2.5/site-packages/MoinMoin/action/AttachFile.py in execute
(pagename=u'MileStones', request=<MoinMoin.request.request_modpython.Request
object at 0x2aaabe10c950>)

  511      handler = globals().get('_do_%s' % do[0])
  512      if handler:
  513          msg = handler(pagename, request)
  514      else:
  515          msg = _('Unsupported AttachFile sub-action: %s') %
(wikiutil.escape(do[0]), )
msg undefined handler = <function _do_upload at 0x2aaabea907d0> pagename =
u'MileStones' request = <MoinMoin.request.request_modpython.Request object
at 0x2aaabe10c950>
/usr/lib/python2.5/site-packages/MoinMoin/action/AttachFile.py in _do_upload
(pagename=u'MileStones', request=<MoinMoin.request.request_modpython.Request
object at 0x2aaabe10c950>)

  590      # add the attachment
  591      try:
  592          target, bytes = add_attachment(request, pagename, target,
filecontent, overwrite=overwrite)
  593          msg = _("Attachment '%(target)s' (remote name
'%(filename)s')"
  594                  " with %(bytes)d bytes saved.") % {
target = u'netbank.pdf' bytes undefined global add_attachment = <function
add_attachment at 0x2aaabea90140> request =
<MoinMoin.request.request_modpython.Request object at 0x2aaabe10c950>
pagename = u'MileStones' filecontent = <closed file '<fdopen>', mode 'w+b'
at 0x2aaabe1135d0> overwrite = 0
/usr/lib/python2.5/site-packages/MoinMoin/action/AttachFile.py in
add_attachment (request=<MoinMoin.request.request_modpython.Request object
at 0x2aaabe10c950>, pagename=u'MileStones', target=u'netbank.pdf',
filecontent=<closed file '<fdopen>', mode 'w+b' at 0x2aaabe1135d0>,
overwrite=0)

  208          stream = open(fpath, 'wb')
  209          try:
  210              _write_stream(filecontent, stream)
  211          finally:
  212              stream.close()
global _write_stream = <function _write_stream at 0x2aaabea900c8>
filecontent = <closed file '<fdopen>', mode 'w+b' at 0x2aaabe1135d0> stream
= <closed file '/var/opt/wiki/gaocandev/data/pages...hments/netbank.pdf',
mode 'wb' at 0x2aaabeaab7b0>
/usr/lib/python2.5/site-packages/MoinMoin/action/AttachFile.py in
_write_stream (content=<closed file '<fdopen>', mode 'w+b' at
0x2aaabe1135d0>, stream=<closed file
'/var/opt/wiki/gaocandev/data/pages...hments/netbank.pdf', mode 'wb' at
0x2aaabeaab7b0>, bufsize=8192)

  175      if hasattr(content, 'read'): # looks file-like
  176          import shutil
  177          shutil.copyfileobj(content, stream, bufsize)
  178      elif isinstance(content, str):
  179          stream.write(content)
shutil = <module 'shutil' from '/usr/lib64/python2.5/shutil.pyc'>
shutil.copyfileobj = <function copyfileobj at 0x2aaabdb30ed8> content =
<closed file '<fdopen>', mode 'w+b' at 0x2aaabe1135d0> stream = <closed file
'/var/opt/wiki/gaocandev/data/pages...hments/netbank.pdf', mode 'wb' at
0x2aaabeaab7b0> bufsize = 8192
/usr/lib64/python2.5/shutil.py in copyfileobj (fsrc=<closed file '<fdopen>',
mode 'w+b' at 0x2aaabe1135d0>, fdst=<closed file
'/var/opt/wiki/gaocandev/data/pages...hments/netbank.pdf', mode 'wb' at
0x2aaabeaab7b0>, length=8192)

   19      """copy data from file-like object fsrc to file-like object
fdst"""
   20      while 1:
   21          buf = fsrc.read(length)
   22          if not buf:
   23              break
buf undefined fsrc = <closed file '<fdopen>', mode 'w+b' at 0x2aaabe1135d0>
fsrc.read = <built-in method read of file object at 0x2aaabe1135d0> length =
8192
ValueError
I/O operation on closed file

args = ('I/O operation on closed file',)
message = 'I/O operation on closed file'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/moin-user/attachments/20080720/99567910/attachment.html>


More information about the Moin-user mailing list