[Zope3-checkins]
SVN: Zope3/branches/stephan_and_jim-response-refactor/src/zope/
Improved all BBB messages and added appropriate comments.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Sep 7 12:13:37 EDT 2005
Log message for revision 38344:
Improved all BBB messages and added appropriate comments.
Changed:
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/httpfactory.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/base.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/ftp.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/http.py
-=-
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/httpfactory.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/httpfactory.py 2005-09-07 16:09:32 UTC (rev 38343)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/httpfactory.py 2005-09-07 16:13:37 UTC (rev 38344)
@@ -65,12 +65,14 @@
def __call__(self, input_stream, env, output_stream=None):
"""See `zope.app.publication.interfaces.IPublicationRequestFactory`"""
- # XXX BBB
+ # BBB: This is backward-compatibility support for the deprecated
+ # output stream.
try:
env.get
except AttributeError:
import warnings
- warnings.warn("Can't pass output streams to requests anymore",
+ warnings.warn("Can't pass output streams to requests anymore. "
+ "This will go away in Zope 3.4.",
DeprecationWarning,
2)
env, output_stream = output_stream, env
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/base.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/base.py 2005-09-07 16:09:32 UTC (rev 38343)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/base.py 2005-09-07 16:13:37 UTC (rev 38344)
@@ -21,6 +21,7 @@
import traceback
from cStringIO import StringIO
+from zope.deprecation import deprecation
from zope.interface import implements, providedBy
from zope.interface.common.mapping import IReadMapping, IEnumerableMapping
@@ -44,10 +45,12 @@
def __init__(self, outstream=None):
self._request = None
- # XXX BBB
+ # 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 responses anymore",
+ warnings.warn("Can't pass output streams to requests anymore. "
+ "This will go away in Zope 3.4.",
DeprecationWarning,
2)
@@ -74,9 +77,13 @@
'See IPublisherResponse'
return self.__class__()
- # XXX: Do BBB properly
+ # BBB: Backward-compatibility for old body API
def setBody(self, body):
return self.setResult(body)
+ setBody = deprecation.deprecated(
+ setBody,
+ 'setBody() has been deprecated in favor of setResult(). '
+ 'This will go away in Zope 3.4.')
class RequestDataGetter(object):
@@ -196,10 +203,12 @@
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'):
- # XXX BBB
import warnings
- warnings.warn("Can't pass output streams to requests anymore",
+ 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
@@ -433,13 +442,15 @@
def __init__(self, path, body_instream=None, environ=None, outstream=None):
- # XXX BBB
+ # 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",
+ warnings.warn("Can't pass output streams to requests anymore. "
+ "This will go away in Zope 3.4.",
DeprecationWarning,
2)
environ, outstream = outstream, environ
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py 2005-09-07 16:09:32 UTC (rev 38343)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py 2005-09-07 16:13:37 UTC (rev 38344)
@@ -610,12 +610,14 @@
}
if environ is not None:
- # XXX BBB
+ # 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",
+ 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
@@ -646,9 +648,10 @@
else:
directlyProvides(self, IDefaultBrowserLayer)
- # XXX BBB
+ # 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()
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/ftp.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/ftp.py 2005-09-07 16:09:32 UTC (rev 38343)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/ftp.py 2005-09-07 16:13:37 UTC (rev 38344)
@@ -39,18 +39,20 @@
__slots__ = '_auth'
- # XXX BBB
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",
+ 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')
-
+
del environ['credentials']
super(FTPRequest, self).__init__(body_instream, environ, response)
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/http.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/http.py 2005-09-07 16:09:32 UTC (rev 38343)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/http.py 2005-09-07 16:13:37 UTC (rev 38344)
@@ -21,6 +21,7 @@
from cgi import escape
from Cookie import SimpleCookie
+from zope.deprecation import deprecation
from zope.interface import implements
from zope.publisher import contenttype
@@ -236,12 +237,14 @@
retry_max_count = 3 # How many times we're willing to retry
def __init__(self, body_instream, environ, response=None, outstream=None):
- # XXX BBB
+ # 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",
+ warnings.warn("Can't pass output streams to requests anymore. "
+ "This will go away in Zope 3.4.",
DeprecationWarning,
2)
environ, response = response, outstream
@@ -550,6 +553,7 @@
__slots__ = (
'authUser', # Authenticated user string
+ # BBB: Remove for Zope 3.4.
'_header_output', # Hook object to collaborate with a server
# for header generation.
'_headers',
@@ -562,7 +566,26 @@
def __init__(self, header_output=None, http_transaction=None):
- # XXX BBB
+ # 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
super(HTTPResponse, self).__init__()
@@ -718,10 +741,12 @@
if not self._status_set:
self.setStatus(200)
- # XXX BBB
- def _body(self):
- return ''.join(self.result.body)
- _body = property(_body)
+ # BBB: Backward-compatibility for old body API
+ _body = property(lambda self: ''.join(self.result.body))
+ _body = deprecation.deprecated(
+ _body,
+ '`_body` has been deprecated in favor of `result`. '
+ 'This will go away in Zope 3.4.')
def _implicitResult(self, body):
encoding = getCharsetUsingRequest(self._request) or 'utf-8'
@@ -796,7 +821,7 @@
"""
Returns a response object to be used in a retry attempt
"""
- return self.__class__(self._header_output)
+ return self.__class__()
def redirect(self, location, status=None):
More information about the Zope3-Checkins
mailing list