[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ use a simpler implementation of the new form submission stuff, and avoid the

Fred L. Drake, Jr. fdrake at gmail.com
Fri Apr 22 14:50:29 EDT 2005


Log message for revision 30114:
  use a simpler implementation of the new form submission stuff, and avoid the
  extra function inserted in the globals of the test code; this also supports
  form variables for GET requests
  

Changed:
  U   Zope3/trunk/src/zope/app/demo/widget/help/textareawidget.txt
  U   Zope3/trunk/src/zope/app/testing/functional.py

-=-
Modified: Zope3/trunk/src/zope/app/demo/widget/help/textareawidget.txt
===================================================================
--- Zope3/trunk/src/zope/app/demo/widget/help/textareawidget.txt	2005-04-22 18:35:09 UTC (rev 30113)
+++ Zope3/trunk/src/zope/app/demo/widget/help/textareawidget.txt	2005-04-22 18:50:28 UTC (rev 30114)
@@ -136,18 +136,18 @@
 
 Add a TextWidget using the addform::
 
-  >>> print post(r"""
+  >>> print http(r"""
   ... POST /widgets/+/addDemoTextAreaWidget.html%3D HTTP/1.1
   ... Authorization: Basic mgr:mgrpw
-  ... """, {"field.standard": "textarea",
-  ...       "field.required": "textarea",
-  ...       "field.constraint": "constraint",
-  ...       "field.default": "default",
-  ...       "field.min_length": "abcdef",
-  ...       "field.max_length": "abcdef",
-  ...       "field.min_max": "abcdef",
-  ...       "UPDATE_SUBMIT": "Add",
-  ...       "add_input_name": "textarea"})
+  ... """, form={"field.standard": "textarea",
+  ...            "field.required": "textarea",
+  ...            "field.constraint": "constraint",
+  ...            "field.default": "default",
+  ...            "field.min_length": "abcdef",
+  ...            "field.max_length": "abcdef",
+  ...            "field.min_max": "abcdef",
+  ...            "UPDATE_SUBMIT": "Add",
+  ...            "add_input_name": "textarea"})
   HTTP/1.1 303 See Other
   ...
         <div class="row">

Modified: Zope3/trunk/src/zope/app/testing/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/functional.py	2005-04-22 18:35:09 UTC (rev 30113)
+++ Zope3/trunk/src/zope/app/testing/functional.py	2005-04-22 18:50:28 UTC (rev 30114)
@@ -537,7 +537,7 @@
 class HTTPCaller(CookieHandler):
     """Execute an HTTP request string via the publisher"""
 
-    def __call__(self, request_string, handle_errors=True):
+    def __call__(self, request_string, handle_errors=True, form=None):
         # Commit work done by previous python code.
         commit()
 
@@ -589,6 +589,11 @@
             # Only browser requests have skins
             interface.directlyProvides(request, _getDefaultSkin())
 
+        if form is not None:
+            if request.form:
+                raise ValueError("only one set of form values can be provided")
+            request.form = form
+
         header_output = HTTPHeaderOutput(
             protocol, ('x-content-type-warning', 'x-powered-by'))
         request.response.setHeaderOutput(header_output)
@@ -604,29 +609,6 @@
 
         return response
 
-    def post(self, request_string, form_fields={}, handle_errors=True):
-        """Encode and perform a POST request.
-
-        This always creates multipart/form-data submissions.
-        """
-        request_string = request_string.strip()
-        if not request_string.startswith("POST "):
-            raise TypeError("request must be a POST")
-        boundary = "--------------------------------------455234523"
-        if form_fields:
-            request_string += "\nContent-Type: multipart/form-data; boundary="
-            request_string += boundary
-        request_string += "\n\n"
-        if form_fields:
-            for name, value in form_fields.iteritems():
-                request_string += "--" + boundary + "\n"
-                request_string += 'Content-Disposition: form-data; name="'
-                request_string += name + '"\n\n'
-                request_string += value + "\n"
-            request_string += "--" + boundary + "--\n"
-        return self.__call__(request_string, handle_errors)
-        
-
     def chooseRequestClass(self, method, path, environment):
         """Choose and return a request class and a publication class"""
 
@@ -660,7 +642,6 @@
 def FunctionalDocFileSuite(*paths, **kw):
     globs = kw.setdefault('globs', {})
     globs['http'] = HTTPCaller()
-    globs['post'] = globs['http'].post
     globs['getRootFolder'] = getRootFolder
     globs['sync'] = sync
 



More information about the Zope3-Checkins mailing list