request_modpython: doing dirty tricks to work around mod_python 3.3.1 problems
authorThomas Waldmann <tw AT waldmann-edv DOT de>
Fri, 18 Jul 2008 19:50:15 +0200
changeset 3758c4cf4327c96e
parent 3757 4f0dcb5fe7a6
child 3759 b13a58a18dac
request_modpython: doing dirty tricks to work around mod_python 3.3.1 problems
MoinMoin/request/request_modpython.py
     1.1 --- a/MoinMoin/request/request_modpython.py	Fri Jul 18 09:54:43 2008 +0200
     1.2 +++ b/MoinMoin/request/request_modpython.py	Fri Jul 18 19:50:15 2008 +0200
     1.3 @@ -103,12 +103,19 @@
     1.4                      fixedResult.append(item.file)
     1.5                      # Remember filenames with a name hack
     1.6                      args[key + '__filename__'] = item.filename
     1.7 +                    # XXX Now it gets extremely dirty to work around a problem in mod_python 3.3.1: XXX
     1.8 +                    # Without the next line, item.file will be closed when item/form leaves this scope.
     1.9 +                    # I guess some reference counting is not implemented correctly for item.file,
    1.10 +                    # so we just keep a reference to item to keep it alive...
    1.11 +                    fixedResult.append(item)  # we are lucky, nobody uses the 2nd list item anyway
    1.12 +                    # If you are reading this, please switch to mod_wsgi. :)
    1.13                  elif isinstance(item, str):
    1.14                      # mod_python 2.7 might return strings instead of Field objects.
    1.15                      fixedResult.append(item)
    1.16              args[key] = fixedResult
    1.17  
    1.18 -        return self.decodeArgs(args)
    1.19 +        result = self.decodeArgs(args)
    1.20 +        return result  # XXX without the hack above, item.file gets closed when returning! XXX
    1.21  
    1.22      def run(self, req):
    1.23          """ mod_python calls this with its request object. We don't