Changeset 2532

Show
Ignore:
Timestamp:
07/28/07 10:11:50 (1 year ago)
Author:
bewst
Message:

TracForgePlugin:

Stop trying to preserve the WSGI stream here; it doesn't work
reliably. As far as we can tell, this requires a Trac patch as shown
in http://trac.edgewall.org/ticket/5697#comment:3

Although Noah claims this can be handled in a pre-request filter, he
hasn't been very forthcoming with details and says he won't have time
to work on it in the near future, so no breath held over here.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tracforgeplugin/branches/bewst/0.11-clearsilver/tracforge/admin/dispatch.py

    r2432 r2532  
    1313import os.path 
    1414import copy 
    15 import urllib 
    1615 
    1716class TracForgeDispatcherModule(Component): 
     
    7372            environ['trac.env_path'] = '' 
    7473 
    75         # Reconstruct the wsgi.input stream from req.args, so dispatch_request 
    76         # can read it again.  If we don't do this, POST data gets lost because 
    77         # the original stream has already been read once. 
    78         if environ['wsgi.input']: 
    79             args = {}  
    80             for k,v in req.args.iteritems(): 
    81                 if isinstance(v, unicode): 
    82                     v = v.encode('utf-8') 
    83                 args[k] = v 
    84             data = urllib.urlencode(args)  
    85             class InputStream: 
    86                 def __init__(self, data): 
    87                     self.data = data 
    88                 def read(self, size=None): 
    89                     result = self.data[:size] 
    90                     self.data = self.data[size:] 
    91                     return result 
    92                  
    93             environ['wsgi.input'] = InputStream(data) 
    94             # This doesn't match up sometimes. Don't know why yet. 
    95             environ['CONTENT_LENGTH'] = len(data) 
    96  
    9774        req._response = dispatch_request(environ, start_response) 
    9875