[Zope3-checkins] CVS: Zope3/src/zope/publisher - http.py:1.48

Dmitry Vasiliev dima at hlabs.spb.ru
Tue Mar 30 04:16:52 EST 2004


Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv369/src/zope/publisher

Modified Files:
	http.py 
Log Message:
More publisher/http.py optimizations. Tests for request.URL.get() added.


=== Zope3/src/zope/publisher/http.py 1.47 => 1.48 ===
--- Zope3/src/zope/publisher/http.py:1.47	Mon Mar 29 09:23:36 2004
+++ Zope3/src/zope/publisher/http.py	Tue Mar 30 04:16:17 2004
@@ -144,6 +144,12 @@
         return self.__request.getURL()
 
     def __getitem__(self, name):
+        url = self.get(name, None)
+        if url is None:
+            raise KeyError, name
+        return url
+
+    def get(self, name, default=None):
         i = int(name)
         try:
             if i < 0:
@@ -153,18 +159,6 @@
                 return self.__request.getApplicationURL(i)
         except IndexError, v:
             if v[0] == i:
-                raise KeyError, name
-            raise
-
-    def get(self, name, default=None):
-        i = int(name)
-        try:
-            if i < 0:
-                return self.__request.getURL(-i)
-            else:
-                return self.__request.getApplicationURL(i)
-        except IndexError, v:
-            if v == i:
                 return default
             raise
 
@@ -884,7 +878,7 @@
         lst = ['Status: %s %s' % (self._status, self._reason)]
         items = m.items()
         items.sort()
-        lst.extend(map(lambda x: '%s: %s' % x, items))
+        lst.extend(['%s: %s' % i for i in items])
         lst.extend(self._cookie_list())
         lst.extend(self._accumulated_headers)
         return ('%s\r\n\r\n' % '\r\n'.join(lst))
@@ -900,11 +894,8 @@
         encode = self._encode
         headers = self.getHeaders()
         # Clean these headers from unicode by possibly encoding them
-        items = headers.items()
-        items = map(lambda i: (encode(i[0]), encode(i[1])), items)
-        headers = {}
-        for key, value in items:
-            headers[key] = value
+        headers = dict([(encode(key), encode(val))
+                        for key, val in headers.iteritems()])
         # Cleaning done.
         header_output = self._header_output
         if header_output is not None:




More information about the Zope3-Checkins mailing list