[Trac-tickets] Re: [The Trac Project] #2284: Delete page exhibits same behaviour as delete version

The Trac Project noreply at edgewall.com
Wed Nov 2 23:50:54 CST 2005


#2284: Delete page exhibits same behaviour as delete version
-----------------------------------+----------------------------------------
 Reporter:  trac-form at swapoff.org  |        Owner:  mgood   
     Type:  defect                 |       Status:  assigned
 Priority:  normal                 |    Milestone:  0.9.1   
Component:  general                |      Version:  0.9     
 Severity:  normal                 |   Resolution:          
 Keywords:                         |  
-----------------------------------+----------------------------------------
Changes (by mgood):

  * status:  new => assigned
  * owner:  jonas => mgood

Comment:

 Well, apparently with the CGI and FastCGI front-ends `req.args` contains
 only POST parameters when the request method is POST, but the mod_python
 front end is wrapping the request in a way that preserves the GET
 arguments as well.  It seems like the cleanest thing would be to make
 mod_python conform to the CGI behavior.  This means that POSTs wouldn't be
 able to access any GET parameters on the URL, though mixing the two should
 probably be avoided anyways and CGI and FastCGI seem to be working fine as
 they are now.

 Unless there are any objections this patch should fix the mod_python
 frontend:

 {{{
 #!diff
 --- trac/web/modpython_frontend.py      (revision 5925)
 +++ trac/web/modpython_frontend.py      (local)
 @@ -138,25 +138,16 @@
          a POST request. We work around this to provide the behaviour of
 cgi.py
          here.
          """
 -        class RequestWrapper(object):
 -            def __init__(self, req):
 -                self.req = req
 -                self.args = ''
 -            def __getattr__(self, name):
 -                return getattr(self.req, name)
 -        util.FieldStorage.__init__(self, RequestWrapper(req),
 keep_blank_values=1)
 +        if req.method == 'POST':
 +            class RequestWrapper(object):
 +                def __init__(self, req):
 +                    self.req = req
 +                    self.args = ''
 +                def __getattr__(self, name):
 +                    return getattr(self.req, name)
 +            req = RequestWrapper(req)
 +        util.FieldStorage.__init__(self, req, keep_blank_values=1)

 -        # Populate FieldStorage with the original query string
 parameters, if
 -        # they aren't already defined through the request body
 -        if req.args:
 -            qsargs = []
 -            for pair in util.parse_qsl(req.args, 1):
 -                if self.has_key(pair[0]):
 -                    continue
 -                qsargs.append(util.Field(pair[0], StringIO(pair[1]),
 -                                         "text/plain", {}, None, {}))
 -            self.list += qsargs
 -
      def get(self, key, default=None):
          # Work around a quirk with the ModPython FieldStorage class.
          # Instances of a string subclass are returned instead of real
 }}}

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/2284>
The Trac Project <http://trac.edgewall.com/>


More information about the Trac-Tickets mailing list