[Zope3-checkins] SVN: Zope3/trunk/ Cleanup 'zope.publisher' API.

Florent Xicluna laxyf at yahoo.fr
Sun Sep 17 11:06:35 EDT 2006


Log message for revision 70212:
  Cleanup 'zope.publisher' API.

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/publisher/base.py
  U   Zope3/trunk/src/zope/publisher/browser.py
  U   Zope3/trunk/src/zope/publisher/ftp.py
  U   Zope3/trunk/src/zope/publisher/http.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2006-09-17 14:45:07 UTC (rev 70211)
+++ Zope3/trunk/doc/CHANGES.txt	2006-09-17 15:06:34 UTC (rev 70212)
@@ -37,6 +37,9 @@
 
     Restructuring
 
+      - Removed deprecated argument 'outstream' from ``zope.publisher``
+        API, and removed other deprecated code.
+
       - Removed deprecated aliases:
 
         * ``UniqueIdUtility`` for ``IntIds``
@@ -54,7 +57,7 @@
         * ``IBrowserIdManager`` for ``IClientIdManager``
 
       - Removed deprecated ``zope.app.file.interfaces.IFileContent``.
-        Use ``zope.app.publication.interfaces.IFileContent``
+        Use ``zope.app.publication.interfaces.IFileContent``.
 
       - Removed deprecated ``zope.app.form.CustomSequenceWidgetFactory``.
         Use ``zope.app.form.CustomWidgetFactory``.

Modified: Zope3/trunk/src/zope/publisher/base.py
===================================================================
--- Zope3/trunk/src/zope/publisher/base.py	2006-09-17 14:45:07 UTC (rev 70211)
+++ Zope3/trunk/src/zope/publisher/base.py	2006-09-17 15:06:34 UTC (rev 70212)
@@ -44,16 +44,8 @@
 
     implements(IResponse)
 
-    def __init__(self, outstream=None):
+    def __init__(self):
         self._request = None
-        # BBB: This is backward-compatibility support for the deprecated
-        # output stream.
-        if outstream is not None:
-            import warnings
-            warnings.warn("Can't pass output streams to requests anymore. "
-                          "This will go away in Zope 3.4.",
-                          DeprecationWarning,
-                          2)
 
     def setResult(self, result):
         'See IPublisherResponse'
@@ -78,15 +70,6 @@
         'See IPublisherResponse'
         return self.__class__()
 
-    # BBB: Backward-compatibility for old body API
-    def setBody(self, body):
-        return self.setResult(body)
-    setBody = deprecated(
-        setBody,
-        'setBody() has been deprecated in favor of setResult(). '
-        'This will go away in Zope 3.4.')
-
-
 class RequestDataGetter(object):
 
     implements(IReadMapping)
@@ -202,19 +185,7 @@
     environment = RequestDataProperty(RequestEnvironment)
 
     def __init__(self, body_instream, environ, response=None,
-                 positional=None, outstream=None):
-
-        # BBB: This is backward-compatibility support for the deprecated
-        # output stream.
-        if not hasattr(environ, 'get'):
-            import warnings
-            warnings.warn("Can't pass output streams to requests anymore. "
-                          "This will go away in Zope 3.4.",
-                          DeprecationWarning,
-                          2)
-            environ, response, positional = response, positional, outstream
-
-
+                 positional=None):
         self._traversal_stack = []
         self._last_obj_traversed = None
         self._traversed_names = []
@@ -331,35 +302,6 @@
 
     bodyStream = property(_getBodyStream)
 
-    ########################################################################
-    # BBB: Deprecated; will go away in Zope 3.4
-
-    def _getBody(self):
-        body = getattr(self, '_body', None)
-        if body is None:
-            s = self._body_instream
-            if s is None:
-                return None # TODO: what should be returned here?
-            body = s.read()
-            self._body = body
-        return body
-
-    body = property(_getBody)
-    body = deprecated(body,
-                      'The ``body`` attribute has been deprecated. Please '
-                      'use the ``bodyStream`` attribute directly. This '
-                      'attribute will go away in Zope 3.4.')
-
-    bodyFile = bodyStream
-    bodyFile = deprecated(bodyFile,
-                          'The ``bodyFile`` attribute has been replaced by '
-                          '``bodyStream``, which is a more accurate name. '
-                          'Streams are not necessarily files, i.e. they are '
-                          'not seekable. This attribute will go away in Zope '
-                          '3.4.')
-
-    ########################################################################
-
     def __len__(self):
         'See Interface.Common.Mapping.IEnumerableMapping'
         return len(self.keys())
@@ -453,40 +395,17 @@
 
     __slots__ = ('_presentation_type', )
 
-    def __init__(self, path, body_instream=None, environ=None, outstream=None):
+    def __init__(self, path, body_instream=None, environ=None):
 
-        # BBB: This is backward-compatibility support for the deprecated
-        # output stream.
         if environ is None:
             environ = {}
-        else:
-            if not hasattr(environ, 'get'):
-                import warnings
-                warnings.warn("Can't pass output streams to requests anymore. "
-                              "This will go away in Zope 3.4.",
-                              DeprecationWarning,
-                              2)
-                environ, outstream = outstream, environ
 
         environ['PATH_INFO'] = path
         if body_instream is None:
             body_instream = StringIO('')
 
         super(TestRequest, self).__init__(body_instream, environ)
-        self.response._outstream = outstream
 
-    def _createResponse(self):
-        return BBBResponse()
-
-class BBBResponse(BaseResponse):
-
-    def outputBody(self):
-        import warnings
-        warnings.warn("Can't pass output streams to requests anymore",
-                      DeprecationWarning,
-                      2)
-        self._outstream.write(self._result)
-
 class DefaultPublication(object):
     """A stub publication.
 

Modified: Zope3/trunk/src/zope/publisher/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/browser.py	2006-09-17 14:45:07 UTC (rev 70211)
+++ Zope3/trunk/src/zope/publisher/browser.py	2006-09-17 15:06:34 UTC (rev 70212)
@@ -609,8 +609,7 @@
     """
 
     def __init__(self, body_instream=None, environ=None, form=None,
-                 skin=None, outstream=None,
-                 **kw):
+                 skin=None, **kw):
 
         _testEnv =  {
             'SERVER_URL':         'http://127.0.0.1',
@@ -620,18 +619,6 @@
             }
 
         if environ is not None:
-            # BBB: This is backward-compatibility support for the deprecated
-            # output stream.
-            try:
-                environ.get
-            except AttributeError:
-                import warnings
-                warnings.warn("Can't pass output streams to requests anymore. "
-                              "This will go away in Zope 3.4.",
-                              DeprecationWarning,
-                              2)
-                environ, form, skin, outstream = form, skin, outstream, environ
-
             _testEnv.update(environ)
 
         if kw:
@@ -658,15 +645,8 @@
         else:
             directlyProvides(self, IDefaultBrowserLayer)
 
-        # BBB: Goes away in 3.4.
-        self.response.outstream = outstream
 
-    # BBB: Remove in 3.4. The super version will be ok.
-    def _createResponse(self):
-        return BBBResponse()
 
-
-
 class BrowserResponse(HTTPResponse):
     """Browser response
     """
@@ -746,30 +726,6 @@
         super(BrowserResponse, self).reset()
         self._base = ''
 
-class BBBResponse(BrowserResponse):
-
-    def write(self, str):
-        import warnings
-        warnings.warn("write() method does not exist anymore.",
-                      DeprecationWarning,
-                      2)
-        self.outstream.write(str)
-
-    def outputBody(self):
-        import warnings
-        warnings.warn("Can't pass output streams to requests anymore",
-                      DeprecationWarning,
-                      2)
-        self.outstream.write("Status: %s\r\n" % self.getStatusString())
-        headers = self.getHeaders()
-        headers.sort()
-        self.outstream.write(
-            "\r\n".join([("%s: %s" % h) for h in headers])
-            + "\r\n\r\n"
-            )
-        self.outstream.write(''.join(self.getBody()))
-
-
 def isHTML(str):
      """Try to determine whether str is HTML or not."""
      s = str.lstrip().lower()

Modified: Zope3/trunk/src/zope/publisher/ftp.py
===================================================================
--- Zope3/trunk/src/zope/publisher/ftp.py	2006-09-17 14:45:07 UTC (rev 70211)
+++ Zope3/trunk/src/zope/publisher/ftp.py	2006-09-17 15:06:34 UTC (rev 70212)
@@ -39,19 +39,8 @@
 
     __slots__ = '_auth'
 
-    def __init__(self, body_instream, environ, response=None, bbb=None):
-        # BBB: This is backward-compatibility support for the deprecated
-        # output stream.
-        try:
-            self._auth = environ.get('credentials')
-        except AttributeError:
-            import warnings
-            warnings.warn("Can't pass output streams to requests anymore. "
-                          "This will go away in Zope 3.4.",
-                          DeprecationWarning,
-                          2)
-            environ, response = response, bbb
-            self._auth = environ.get('credentials')
+    def __init__(self, body_instream, environ, response=None):
+        self._auth = environ.get('credentials')
 
         del environ['credentials']
 

Modified: Zope3/trunk/src/zope/publisher/http.py
===================================================================
--- Zope3/trunk/src/zope/publisher/http.py	2006-09-17 14:45:07 UTC (rev 70211)
+++ Zope3/trunk/src/zope/publisher/http.py	2006-09-17 15:06:34 UTC (rev 70212)
@@ -284,21 +284,7 @@
 
     retry_max_count = 3    # How many times we're willing to retry
 
-    def __init__(self, body_instream, environ, response=None, outstream=None):
-        # BBB: This is backward-compatibility support for the deprecated
-        # output stream.
-        try:
-            environ.get
-        except AttributeError:
-            import warnings
-            warnings.warn("Can't pass output streams to requests anymore. "
-                          "This will go away in Zope 3.4.",
-                          DeprecationWarning,
-                          # HTTPRequest.__init__() mostly called through
-                          # BrowserRequest.__init__() so we need to shift
-                          # to another one step backward.
-                          3)
-            environ, response = response, outstream
+    def __init__(self, body_instream, environ, response=None):
 
         super(HTTPRequest, self).__init__(
             HTTPInputStream(body_instream, environ), environ, response)
@@ -647,29 +633,7 @@
         )
 
 
-    def __init__(self, header_output=None, http_transaction=None):
-        # BBB: Both, header_output and http_transaction have been deprecated.
-        if header_output is not None:
-            import warnings
-            warnings.warn(
-                "The header output API is completely deprecated. It's "
-                "intentions were not clear and it duplicated APIs in the "
-                "response, which you should use instead. "
-                "This will go away in Zope 3.4.",
-                DeprecationWarning, 2)
-
-        if http_transaction is not None:
-            import warnings
-            warnings.warn(
-                "Storing the HTTP transaction here was a *huge* hack to "
-                "support transporting the authenticated user string "
-                "to the server. You should never rely on this variable "
-                "anyways. "
-                "This will go away in Zope 3.4.",
-                DeprecationWarning, 2)
-
-        self._header_output = header_output
-
+    def __init__(self):
         super(HTTPResponse, self).__init__()
         self.reset()
 
@@ -839,14 +803,6 @@
         return self._result.body
 
 
-    # BBB: Backward-compatibility for old body API
-    _body = property(consumeBody)
-    _body = deprecation.deprecated(
-        _body,
-        '`_body` has been deprecated in favor of `consumeBody()`. '
-        'This will go away in Zope 3.4.')
-
-
     def _implicitResult(self, body):
         encoding = getCharsetUsingRequest(self._request) or 'utf-8'
         content_type = self.getHeader('content-type')



More information about the Zope3-Checkins mailing list