[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher - BaseRequest.py:1.1.2.5 DefaultPublication.py:1.1.2.3 IPublication.py:1.1.2.5 Publish.py:1.1.2.5 minitest.py:1.1.2.2

Shane Hathaway shane@digicool.com
Thu, 15 Nov 2001 18:10:02 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Publisher
In directory cvs.zope.org:/tmp/cvs-serv16729

Modified Files:
      Tag: Zope-3x-branch
	BaseRequest.py DefaultPublication.py IPublication.py 
	Publish.py minitest.py 
Log Message:
- Divided the HTTP protocol from its payload

- Expanded minitest

- Renamed some interface methods


=== Zope3/lib/python/Zope/Publisher/BaseRequest.py 1.1.2.4 => 1.1.2.5 ===
 
 
-class RequestContainer:
-    # TODO: add security assertion declaring this to be public
-
-    def __init__(self, request):
-        self.REQUEST = request
-
-
-
 _marker = []
 
 class BaseRequest:
@@ -30,8 +22,6 @@
     collection of variable to value mappings.
     """
 
-    # TODO: add security assertion declaring this to be public
-
     body_instream = None  # The body input stream
     common = {}           # Data common to all requests
     args = ()             # Positional arguments
@@ -39,11 +29,11 @@
     # _held contains objects kept until the request is closed,
     # such as the database connection closer.
     _held = ()
-    _request_default = None  # Overrides publication.getDefault().
+    _request_default = None  # Overrides publication.getDefaultTraversal().
     _body = None             # Cached body
 
     # URL is a string built up during traversal and url_quoted.
-    # It does not include names built from publication.getDefault().
+    # It does not include names built from publication.getDefaultTraversal().
     URL = ''
     to_traverse = ()   # A sequence containing the names to traverse, reversed.
     steps = ()         # A sequence of names built up during traversal.
@@ -182,7 +172,7 @@
     def setRequestDefault(self, path):
         """
         Adds the specified steps to the URL, overriding
-        publication.getDefault().
+        publication.getDefaultTraversal().
         """
         steps = path.split('/')
         steps.reverse()
@@ -280,7 +270,8 @@
                 added_default = 1
                 add_steps = self._request_default
                 if add_steps is None:
-                    object, add_steps = publication.getDefault(self, object)
+                    object, add_steps = publication.getDefaultTraversal(
+                        self, object)
                 if add_steps:
                     to_traverse.extend(add_steps)
 


=== Zope3/lib/python/Zope/Publisher/DefaultPublication.py 1.1.2.2 => 1.1.2.3 ===
         self.app = app
 
-    def preTraversal(self, request):
+    def beforeTraversal(self, request):
         pass
 
     def getApplication(self, request):
@@ -35,16 +35,16 @@
                              request.getURL())
         return subob
 
-    def getDefault(self, request, ob):
+    def getDefaultTraversal(self, request, ob):
         return ob, None
 
-    def postTraversal(self, request, ob):
+    def afterTraversal(self, request, ob):
         pass
 
-    def publish(self, request, ob):
+    def callObject(self, request, ob):
         return mapply(ob, request.args, request)
 
-    def postPublish(self, request):
+    def afterCall(self, request):
         pass
 
     def handleException(self, request, exc, retry_allowed=1):


=== Zope3/lib/python/Zope/Publisher/IPublication.py 1.1.2.4 => 1.1.2.5 ===
         """
 
-    def preTraversal(request):
+    def beforeTraversal(request):
         """
         Pre-traversal hook.
         """
@@ -37,28 +37,28 @@
         Returns the subobject.
         """
 
-    def getDefault(request, ob):
+    def getDefaultTraversal(request, ob):
         """
         Allows a default view to be added to traversal.
         Returns (ob, steps_reversed).
         """
 
-    def postTraversal(request, ob):
+    def afterTraversal(request, ob):
         """
         Post-traversal hook.
         """
 
-    def publish(request, ob):
+    def callObject(request, ob):
         """
-        Publishes the object, returning the result as a string.
+        Calls the object, returning the result as a string.
         For GET/POST this means calling it, but for other methods
-        (including those of WebDAV and FTP) this means invoking
+        (including those of WebDAV and FTP) this might mean invoking
         a method of an adapter.
         """
 
-    def postPublish(request):
+    def afterCall(request):
         """
-        Post-publishing hook (if publishing was successful).
+        Post-callObject hook (if it was successful).
         """
 
     def handleException(request, exc_info, retry_allowed=1):


=== Zope3/lib/python/Zope/Publisher/Publish.py 1.1.2.4 => 1.1.2.5 ===
         response = request.response
     
-        publication.preTraversal(request)
+        publication.beforeTraversal(request)
         #if transactions_manager: transactions_manager.begin()
     
         object = publication.getApplication(request)
         path_str = request.get('PATH_INFO', '').strip()
         object = request.traverse(publication, object, path_str)
     
-        publication.postTraversal(request, object)
+        publication.afterTraversal(request, object)
 
-        result = publication.publish(request, object)
+        result = publication.callObject(request, object)
 ##        if transactions_manager:
 ##            transactions_manager.recordMetaData(object, request)
     
@@ -39,7 +39,7 @@
         if result is not response:
             response.setBody(result)
 
-        publication.postPublish(request)
+        publication.afterCall(request)
 ##        if transactions_manager: transactions_manager.commit()
 
         return response


=== Zope3/lib/python/Zope/Publisher/minitest.py 1.1.2.1 => 1.1.2.2 ===
 publish(publication, request)
 
+
+# bogus speed test ;-)
+
+class DevNull:
+    def write(self, s):
+        pass
+devnull = DevNull()
+
+from time import clock
+count = 1000
+start = clock()
+for n in range(count):
+    response = HTTPResponse(devnull)
+    environ = {
+        'SERVER_NAME': 'test',
+        'PATH_INFO': sys.argv[1]
+        }
+    request = HTTPRequest(sys.stdin, environ, response)
+    publish(publication, request)
+end = clock()
+print '%d requests/sec' % (count / (end - start))
+