[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher - BaseResponse.py:1.1.2.8.6.3
Stephan Richter
srichter@cbu.edu
Fri, 22 Mar 2002 00:17:55 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher
In directory cvs.zope.org:/tmp/cvs-serv30302
Modified Files:
Tag: Zope3-publisher-refactor-branch
BaseResponse.py
Log Message:
Cleaned up class. Threw some unneeded attributes away and renamed some
files.
Made it interface aware.
=== Zope3/lib/python/Zope/Publisher/BaseResponse.py 1.1.2.8.6.2 => 1.1.2.8.6.3 ===
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
-# Version 1.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
'''Response Output formatter
-$Id$'''
-__version__='$Revision$'[11:-2]
+$Id$
+'''
+
-from Exceptions import Unauthorized
import traceback
+from IPublisherResponse import IPublisherResponse
+from IApplicationResponse import IApplicationResponse
+
+
+class IResponse(IPublisherResponse, IApplicationResponse):
+ """The basic response contract
+ """
+
class BaseResponse(object):
"""Base Response Class
What should be here?
"""
- debug_mode=None
- status = None # The response status (usually an integer)
- body = ''
- base = None
- #_auth=None
- #_error_format='text/plain'
+
+ __implements__ = IResponse
+
+ _body = ''
+
def __init__(self, outstream):
- self.outstream = outstream
+ self._outstream = outstream
- def outputBody(self):
- """Output the response body.
- """
- self.outstream.write(self._getBody())
+ ############################################################
+ # Implementation methods for interface
+ # Zope.Publisher.BaseResponse.IResponse
- def write(self, string):
- self.body += string
+ ######################################
+ # from: Zope.Publisher.IPublisherResponse.IPublisherResponse
+
+ def outputBody(self):
+ 'See Zope.Publisher.IPublisherResponse.IPublisherResponse'
+ self._outstream.write(self._getBody())
- def setBody(self, body):
- self.body = body
+ def setBody(self, result):
+ 'See Zope.Publisher.IPublisherResponse.IPublisherResponse'
+ self._body = body
+ # This method is not part of this interface
def _getBody(self):
'Returns a string representing the currently set body.'
- return self.body
+ return self._body
def handleException(self, exc_info):
+ 'See Zope.Publisher.IPublisherResponse.IPublisherResponse'
traceback.print_exception(
exc_info[0], exc_info[1], exc_info[2], 100, self)
def retry(self):
+ 'See Zope.Publisher.IPublisherResponse.IPublisherResponse'
return self.__class__(self.outstream)
-
+ ######################################
+ # from: Zope.Publisher.IApplicationResponse.IApplicationResponse
+
+ def write(self, string):
+ 'See Zope.Publisher.IApplicationResponse.IApplicationResponse'
+ self._body += string
+
+ #
+ ############################################################