[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/ Fixed issue #394: starting zope with command -C arg

Dmitry Vasiliev dima at hlabs.spb.ru
Mon Apr 11 09:26:38 EDT 2005


Log message for revision 29942:
  Fixed issue #394: starting zope with command -C arg
  causes request.form to contain '-C':''
  

Changed:
  U   Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt
  U   Zope3/branches/ZopeX3-3.0/src/zope/publisher/browser.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/publisher/tests/test_browserrequest.py

-=-
Modified: Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt
===================================================================
--- Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt	2005-04-11 12:56:59 UTC (rev 29941)
+++ Zope3/branches/ZopeX3-3.0/doc/CHANGES.txt	2005-04-11 13:26:38 UTC (rev 29942)
@@ -10,6 +10,9 @@
 
     Bug Fixes
 
+      - Fixed issue 394 (starting zope with command -C arg
+        causes request.form to contain '-C':'').
+
       - Fixed issue 334 (Failing RuntimeInfo tests).
 
       - Fixed issue 293 (sequence widget).

Modified: Zope3/branches/ZopeX3-3.0/src/zope/publisher/browser.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/publisher/browser.py	2005-04-11 12:56:59 UTC (rev 29941)
+++ Zope3/branches/ZopeX3-3.0/src/zope/publisher/browser.py	2005-04-11 13:26:38 UTC (rev 29942)
@@ -245,6 +245,12 @@
         else:
             fp = None
 
+        # If 'QUERY_STRING' is not present in self._environ
+        # FieldStorage will try to get it from sys.argv[1]
+        # which is not what we need.
+        if 'QUERY_STRING' not in self._environ:
+            self._environ['QUERY_STRING'] = ''
+
         fs = FieldStorage(fp=fp, environ=self._environ, keep_blank_values=1)
 
         fslist = getattr(fs, 'list', None)

Modified: Zope3/branches/ZopeX3-3.0/src/zope/publisher/tests/test_browserrequest.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/publisher/tests/test_browserrequest.py	2005-04-11 12:56:59 UTC (rev 29941)
+++ Zope3/branches/ZopeX3-3.0/src/zope/publisher/tests/test_browserrequest.py	2005-04-11 13:26:38 UTC (rev 29942)
@@ -15,6 +15,7 @@
 
 $Id$
 """
+import sys
 import unittest
 
 from zope.publisher.http import HTTPCharsets
@@ -31,6 +32,8 @@
 from zope.publisher.tests.test_http import HTTPTests
 
 from zope.publisher.publish import publish as publish_
+
+
 def publish(request):
     publish_(request, handle_errors=0)
 
@@ -389,6 +392,18 @@
         verifyObject(IBrowserRequest, request)
         verifyObject(IBrowserApplicationRequest, request)
 
+    def testIssue394(self):
+        extra = {'PATH_INFO': '/folder/item3/'}
+        request = self._createRequest(extra)
+        del request._environ["QUERY_STRING"]
+        argv = sys.argv
+        sys.argv = [argv[0], "test"]
+        try:
+            publish(request)
+            self.assertEqual(request.form, {})
+        finally:
+            sys.argv = argv
+
 def test_suite():
     loader = unittest.TestLoader()
     return loader.loadTestsFromTestCase(BrowserTests)



More information about the Zope3-Checkins mailing list