[Zope3-checkins]
SVN: Zope3/branches/stephan_and_jim-response-refactor/src/zope/
No more deprecation warnings.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Sep 7 13:41:07 EDT 2005
Log message for revision 38346:
No more deprecation warnings.
Changed:
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/propfind.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/proppatch.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/tests/test_propfind.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/tests/test_proppatch.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/http/tests/test_put.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/i18n/browser/tests/test_translate.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/browser.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_browserpublication.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_http.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_httpfactory.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_zopepublication.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/zopepublication.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/__init__.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/configure.zcml
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/ftp.py
D Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/http.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/wsgi.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/http.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/session.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/tests.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/tests/publication.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_baserequest.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_baseresponse.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_browserrequest.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_browserresponse.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_ftp.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_http.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_ipublication.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_xmlrpcrequest.py
-=-
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/propfind.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/propfind.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/propfind.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -96,7 +96,7 @@
self._depthRecurse(ms)
body = resp.toxml('utf-8')
- self.request.response.setBody(body)
+ self.request.response.setResult(body)
self.request.response.setStatus(207)
self.request.response.setHeader('content-type', 'text/xml')
return body
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/proppatch.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/proppatch.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/proppatch.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -47,13 +47,13 @@
_avail_props = {}
# List all *registered* DAV interface namespaces and their properties
for ns, iface in zapi.getUtilitiesFor(IDAVNamespace):
- _avail_props[ns] = getFieldNamesInOrder(iface)
+ _avail_props[ns] = getFieldNamesInOrder(iface)
# List all opaque DAV namespaces and the properties we know of
if self.oprops:
for ns, oprops in self.oprops.items():
_avail_props[ns] = list(oprops.keys())
self.avail_props = _avail_props
-
+
def PROPPATCH(self):
if self.content_type not in ['text/xml', 'application/xml']:
self.request.response.setStatus(400)
@@ -73,7 +73,7 @@
ms.lastChild.appendChild(resp.createElement('href'))
ms.lastChild.lastChild.appendChild(resp.createTextNode(resource_url))
- updateel = xmldoc.getElementsByTagNameNS(self.default_ns,
+ updateel = xmldoc.getElementsByTagNameNS(self.default_ns,
'propertyupdate')
if not updateel:
self.request.response.setStatus(422)
@@ -87,7 +87,7 @@
self._handlePropertyUpdate(resp, updates)
body = resp.toxml('utf-8')
- self.request.response.setBody(body)
+ self.request.response.setResult(body)
self.request.response.setStatus(207)
return body
@@ -108,7 +108,7 @@
props = results.setdefault(node.namespaceURI, [])
if node.localName not in props:
props.append(node.localName)
-
+
if _propresults.keys() != [200]:
# At least some props failed, abort transaction
transaction.abort()
@@ -119,7 +119,7 @@
failed_props = failed.setdefault(ns, [])
failed_props.extend(props)
del _propresults[200]
-
+
# Create the response document
re = resp.lastChild.lastChild
for status, results in _propresults.items():
@@ -156,30 +156,30 @@
props.append(prop.localName)
return 200
return 403
-
+
if not prop.localName in self.avail_props[ns]:
return 403 # Cannot add propeties to a registered schema
-
+
fields = getFields(iface)
field = fields[prop.localName]
if field.readonly:
return 409 # RFC 2518 specifies 409 for readonly props
-
+
value = field.get(iface(self.context))
if value is field.missing_value:
value = no_value
setUpWidget(self, prop.localName, field, IDAVWidget,
value=value, ignoreStickyValues=True)
-
+
widget = getattr(self, prop.localName + '_widget')
widget.setRenderedValue(prop)
if not widget.hasValidInput():
return 409 # Didn't match the widget validation
-
+
if widget.applyChanges(iface(self.context)):
return 200
-
+
return 422 # Field didn't accept the value
def _handleRemove(self, prop):
@@ -193,20 +193,20 @@
return 200
self.oprops.removeProperty(ns, prop.localName)
return 200
-
+
# Registered interfaces
fields = getFields(iface)
field = fields[prop.localName]
if field.readonly:
return 409 # RFC 2518 specifies 409 for readonly props
-
+
if field.required:
if field.default is None:
return 409 # Clearing a required property is a conflict
# Reset the field to the default if a value is required
field.set(iface(self.context), field.default)
return 200
-
+
# Reset the field to it's defined missing_value
field.set(iface(self.context), field.missing_value)
return 200
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/tests/test_propfind.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/tests/test_propfind.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/tests/test_propfind.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -267,7 +267,7 @@
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 207)
self.assertEqual(pfind.getDepth(), depth)
- s1 = normalize_xml(request.response._body)
+ s1 = normalize_xml(''.join(request.response.result.body))
s2 = normalize_xml(expect)
self.assertEqual(s1, s2)
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/tests/test_proppatch.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/tests/test_proppatch.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/dav/tests/test_proppatch.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -28,7 +28,7 @@
from zope.publisher.http import status_reasons
from zope.pagetemplate.tests.util import normalize_xml
from ZODB.tests.util import DB
-
+
from zope.app import zapi
from zope.app.testing import ztapi
@@ -70,7 +70,7 @@
''.join(remove))
for prefix, ns in namespaces:
nsAttrs += ' xmlns:%s="%s"' % (prefix, ns)
-
+
body = '''<?xml version="1.0" encoding="utf-8"?>
<propertyupdate xmlns="DAV:"%s>
@@ -108,7 +108,7 @@
implements(ITestSchema)
__used_for__ = IAnnotatable
annotations = None
-
+
def __init__(self, context):
annotations = IAnnotations(context)
data = annotations.get(TestKey)
@@ -119,7 +119,7 @@
u'unusualMissingValue': (EmptyTestValue,),
u'constrained': (EmptyTestValue,)}
self._mapping = data
-
+
def _changed(self):
if self.annotations is not None:
self.annotations[TestKey] = self._mapping
@@ -171,7 +171,7 @@
root = self.conn.root()
root['Application'] = self.rootFolder
transaction.commit()
-
+
def tearDown(self):
self.db.close()
@@ -222,7 +222,7 @@
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 207)
self.assertEqual(ppatch.content_type, 'text/xml')
-
+
def test_noupdates(self):
file = self.file
request = _createRequest(namespaces=(), set=(), remove=())
@@ -230,9 +230,9 @@
ppatch.PROPPATCH()
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 422)
-
+
def _checkProppatch(self, obj, ns=(), set=(), rm=(), extra='', expect=''):
- request = _createRequest(namespaces=ns, set=set, remove=rm,
+ request = _createRequest(namespaces=ns, set=set, remove=rm,
extra=extra)
resource_url = zapi.absoluteURL(obj, request)
expect = '''<?xml version="1.0" encoding="utf-8"?>
@@ -246,10 +246,10 @@
ppatch.PROPPATCH()
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 207)
- s1 = normalize_xml(request.response._body)
+ s1 = normalize_xml(''.join(request.response.result.body))
s2 = normalize_xml(expect)
self.assertEqual(s1, s2)
-
+
def _makePropstat(self, ns, properties, status=200):
nsattrs = ''
count = 0
@@ -268,37 +268,37 @@
namespacesA.sort()
namespacesB = expect.keys()
namespacesB.sort()
- self.assertEqual(namespacesA, namespacesB,
+ self.assertEqual(namespacesA, namespacesB,
'available opaque namespaces were %s, '
'expected %s' % (namespacesA, namespacesB))
-
+
for ns in namespacesA:
propnamesA = list(oprops[ns].keys())
propnamesA.sort()
propnamesB = expect[ns].keys()
propnamesB.sort()
- self.assertEqual(propnamesA, propnamesB,
+ self.assertEqual(propnamesA, propnamesB,
'props for opaque namespaces %s were %s, '
'expected %s' % (ns, propnamesA, propnamesB))
for prop in propnamesA:
valueA = oprops[ns][prop]
valueB = expect[ns][prop]
- self.assertEqual(valueA, valueB,
+ self.assertEqual(valueA, valueB,
'opaque prop %s:%s was %s, '
'expected %s' % (ns, prop, valueA, valueB))
-
+
def test_removenonexisting(self):
expect = self._makePropstat(('uri://foo',), '<bar xmlns="a0"/>')
self._checkProppatch(self.zpt, ns=(('foo', 'uri://foo'),),
rm=('<foo:bar />'), expect=expect)
-
+
def test_opaque_set_simple(self):
expect = self._makePropstat(('uri://foo',), '<bar xmlns="a0"/>')
self._checkProppatch(self.zpt, ns=(('foo', 'uri://foo'),),
set=('<foo:bar>spam</foo:bar>'), expect=expect)
- self._assertOPropsEqual(self.zpt,
+ self._assertOPropsEqual(self.zpt,
{u'uri://foo': {u'bar': '<bar>spam</bar>'}})
-
+
def test_opaque_remove_simple(self):
oprops = IDAVOpaqueNamespaces(self.zpt)
oprops['uri://foo'] = {'bar': '<bar>eggs</bar>'}
@@ -306,26 +306,26 @@
self._checkProppatch(self.zpt, ns=(('foo', 'uri://foo'),),
rm=('<foo:bar>spam</foo:bar>'), expect=expect)
self._assertOPropsEqual(self.zpt, {})
-
+
def test_opaque_add_and_replace(self):
oprops = IDAVOpaqueNamespaces(self.zpt)
oprops['uri://foo'] = {'bar': '<bar>eggs</bar>'}
expect = self._makePropstat(
- ('uri://castle', 'uri://foo'),
+ ('uri://castle', 'uri://foo'),
'<camelot xmlns="a0"/><bar xmlns="a1"/>')
- self._checkProppatch(self.zpt,
+ self._checkProppatch(self.zpt,
ns=(('foo', 'uri://foo'), ('c', 'uri://castle')),
- set=('<foo:bar>spam</foo:bar>',
+ set=('<foo:bar>spam</foo:bar>',
'<c:camelot place="silly" xmlns:k="uri://knights">'
' <k:roundtable/>'
- '</c:camelot>'),
+ '</c:camelot>'),
expect=expect)
self._assertOPropsEqual(self.zpt, {
u'uri://foo': {u'bar': '<bar>spam</bar>'},
- u'uri://castle': {u'camelot':
+ u'uri://castle': {u'camelot':
'<camelot place="silly" xmlns:p0="uri://knights">'
' <p0:roundtable/></camelot>'}})
-
+
def test_opaque_set_and_remove(self):
expect = self._makePropstat(
('uri://foo',), '<bar xmlns="a0"/>')
@@ -333,7 +333,7 @@
set=('<foo:bar>eggs</foo:bar>',), rm=('<foo:bar/>',),
expect=expect)
self._assertOPropsEqual(self.zpt, {})
-
+
def test_opaque_complex(self):
# PROPPATCH allows us to set, remove and set the same property, ordered
expect = self._makePropstat(
@@ -342,45 +342,45 @@
set=('<foo:bar>spam</foo:bar>',), rm=('<foo:bar/>',),
extra='<set><prop><foo:bar>spam</foo:bar></prop></set>',
expect=expect)
- self._assertOPropsEqual(self.zpt,
+ self._assertOPropsEqual(self.zpt,
{u'uri://foo': {u'bar': '<bar>spam</bar>'}})
-
+
def test_proppatch_failure(self):
expect = self._makePropstat(
('uri://foo',), '<bar xmlns="a0"/>', 424)
expect += self._makePropstat(
('http://www.purl.org/dc/1.1',), '<nonesuch xmlns="a0"/>', 403)
- self._checkProppatch(self.zpt,
+ self._checkProppatch(self.zpt,
ns=(('foo', 'uri://foo'), ('DC', 'http://www.purl.org/dc/1.1')),
set=('<foo:bar>spam</foo:bar>', '<DC:nonesuch>Test</DC:nonesuch>'),
expect=expect)
self._assertOPropsEqual(self.zpt, {})
-
+
def test_nonexistent_dc(self):
expect = self._makePropstat(
('http://www.purl.org/dc/1.1',), '<nonesuch xmlns="a0"/>', 403)
- self._checkProppatch(self.zpt,
+ self._checkProppatch(self.zpt,
ns=(('DC', 'http://www.purl.org/dc/1.1'),),
set=('<DC:nonesuch>Test</DC:nonesuch>',), expect=expect)
-
+
def test_set_readonly(self):
expect = self._makePropstat((), '<getcontentlength/>', 409)
- self._checkProppatch(self.zpt,
+ self._checkProppatch(self.zpt,
set=('<getcontentlength>Test</getcontentlength>',), expect=expect)
-
+
def test_remove_readonly(self):
expect = self._makePropstat((), '<getcontentlength/>', 409)
- self._checkProppatch(self.zpt, rm=('<getcontentlength/>',),
+ self._checkProppatch(self.zpt, rm=('<getcontentlength/>',),
expect=expect)
def test_remove_required_no_default(self):
testprops = ITestSchema(self.zpt)
testprops.requiredNoDefault = u'foo'
transaction.commit()
- expect = self._makePropstat((TestURI,),
+ expect = self._makePropstat((TestURI,),
'<requiredNoDefault xmlns="a0"/>', 409)
- self._checkProppatch(self.zpt,
- ns=(('tst', TestURI),), rm=('<tst:requiredNoDefault/>',),
+ self._checkProppatch(self.zpt,
+ ns=(('tst', TestURI),), rm=('<tst:requiredNoDefault/>',),
expect=expect)
self.assertEqual(ITestSchema(self.zpt).requiredNoDefault, u'foo')
@@ -388,10 +388,10 @@
testprops = ITestSchema(self.zpt)
testprops.requiredDefault = u'foo'
transaction.commit()
- expect = self._makePropstat((TestURI,),
+ expect = self._makePropstat((TestURI,),
'<requiredDefault xmlns="a0"/>', 200)
- self._checkProppatch(self.zpt,
- ns=(('tst', TestURI),), rm=('<tst:requiredDefault/>',),
+ self._checkProppatch(self.zpt,
+ ns=(('tst', TestURI),), rm=('<tst:requiredDefault/>',),
expect=expect)
self.assertEqual(testprops.requiredDefault, u'Default Value')
@@ -399,10 +399,10 @@
testprops = ITestSchema(self.zpt)
testprops.unusualMissingValue = u'foo'
transaction.commit()
- expect = self._makePropstat((TestURI,),
+ expect = self._makePropstat((TestURI,),
'<unusualMissingValue xmlns="a0"/>', 200)
- self._checkProppatch(self.zpt,
- ns=(('tst', TestURI),), rm=('<tst:unusualMissingValue/>',),
+ self._checkProppatch(self.zpt,
+ ns=(('tst', TestURI),), rm=('<tst:unusualMissingValue/>',),
expect=expect)
self.assertEqual(testprops.unusualMissingValue, u'Missing Value')
@@ -410,11 +410,11 @@
dc = IZopeDublinCore(self.zpt)
dc.title = u'Test Title'
transaction.commit()
- expect = self._makePropstat(('http://www.purl.org/dc/1.1',),
+ expect = self._makePropstat(('http://www.purl.org/dc/1.1',),
'<title xmlns="a0"/>', 200)
- self._checkProppatch(self.zpt,
- ns=(('DC', 'http://www.purl.org/dc/1.1'),),
- set=('<DC:title>Foo Bar</DC:title>',),
+ self._checkProppatch(self.zpt,
+ ns=(('DC', 'http://www.purl.org/dc/1.1'),),
+ set=('<DC:title>Foo Bar</DC:title>',),
expect=expect)
self.assertEqual(dc.title, u'Foo Bar')
@@ -422,11 +422,11 @@
dc = IZopeDublinCore(self.zpt)
dc.subjects = (u'Bla', u'Ble', u'Bli')
transaction.commit()
- expect = self._makePropstat(('http://www.purl.org/dc/1.1',),
+ expect = self._makePropstat(('http://www.purl.org/dc/1.1',),
'<subjects xmlns="a0"/>', 200)
- self._checkProppatch(self.zpt,
- ns=(('DC', 'http://www.purl.org/dc/1.1'),),
- set=('<DC:subjects>Foo, Bar</DC:subjects>',),
+ self._checkProppatch(self.zpt,
+ ns=(('DC', 'http://www.purl.org/dc/1.1'),),
+ set=('<DC:subjects>Foo, Bar</DC:subjects>',),
expect=expect)
self.assertEqual(dc.subjects, (u'Foo', u'Bar'))
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/http/tests/test_put.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/http/tests/test_put.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/http/tests/test_put.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -52,7 +52,7 @@
def test(self):
container = Container()
content = "some content\n for testing"
- request = TestRequest(StringIO(content),
+ request = TestRequest(StringIO(content),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': str(len(content)),
})
@@ -60,7 +60,7 @@
put = zope.app.http.put.NullPUT(null, request)
self.assertEqual(getattr(container, 'spam', None), None)
self.assertEqual(put.PUT(), '')
- request.response.setBody('')
+ request.response.setResult('')
file = container.spam
self.assertEqual(file.__class__, File)
self.assertEqual(file.name, 'spam')
@@ -73,7 +73,7 @@
def test_bad_content_header(self):
container = Container()
content = "some content\n for testing"
- request = TestRequest(StringIO(content),
+ request = TestRequest(StringIO(content),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': str(len(content)),
'HTTP_CONTENT_FOO': 'Bar',
@@ -82,7 +82,7 @@
put = zope.app.http.put.NullPUT(null, request)
self.assertEqual(getattr(container, 'spam', None), None)
self.assertEqual(put.PUT(), '')
- request.response.setBody('')
+ request.response.setResult('')
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 501)
@@ -92,26 +92,26 @@
def test(self):
file = File("thefile", "text/x", "initial content")
content = "some content\n for testing"
- request = TestRequest(StringIO(content),
+ request = TestRequest(StringIO(content),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': str(len(content)),
})
put = zope.app.http.put.FilePUT(file, request)
self.assertEqual(put.PUT(), '')
- request.response.setBody('')
+ request.response.setResult('')
self.assertEqual(file.data, content)
def test_bad_content_header(self):
file = File("thefile", "text/x", "initial content")
content = "some content\n for testing"
- request = TestRequest(StringIO(content),
+ request = TestRequest(StringIO(content),
{'CONTENT_TYPE': 'test/foo',
'CONTENT_LENGTH': str(len(content)),
'HTTP_CONTENT_FOO': 'Bar',
})
put = zope.app.http.put.FilePUT(file, request)
self.assertEqual(put.PUT(), '')
- request.response.setBody('')
+ request.response.setResult('')
self.assertEqual(file.data, "initial content")
# Check HTTP Response
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/i18n/browser/tests/test_translate.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/i18n/browser/tests/test_translate.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/i18n/browser/tests/test_translate.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -38,8 +38,8 @@
def __init__(self, context, request):
self.context = context
self.request = request
-
+
class TranslateTest(PlacelessSetup, unittest.TestCase):
def setUp(self):
@@ -71,7 +71,7 @@
def _getRequest(self, **kw):
- request = BrowserRequest(StringIO(''), StringIO(), kw)
+ request = BrowserRequest(StringIO(''), kw)
request._cookies = {'edit_languages': 'en,de'}
request._traversed_names = ['foo', 'bar']
return request
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/browser.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/browser.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/browser.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -69,7 +69,7 @@
def afterCall(self, request, ob):
super(BrowserPublication, self).afterCall(request, ob)
if request.method == 'HEAD':
- request.response.setBody('')
+ request.response.setResult('')
# For now, have a factory that returns a singleton
class PublicationFactory(object):
@@ -130,7 +130,7 @@
Any interfaces that are directly provided by the request coming into this
method are replaced by the applied layer/skin interface:
-
+
>>> request = Request()
>>> class IFoo(Interface):
... pass
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_browserpublication.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_browserpublication.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_browserpublication.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -258,7 +258,7 @@
# With a normal request, we should get a body:
request = TestRequest(StringIO(''), {'PATH_INFO': '/'})
request.setPrincipal(User())
- request.response.setBody(u"spam")
+ request.response.setResult(u"spam")
pub.afterCall(request, None)
self.assertEqual(request.response.testBody(), 'spam' )
@@ -266,31 +266,32 @@
request = TestRequest(StringIO(''), {'PATH_INFO': '/'})
request.setPrincipal(User())
request.method = 'HEAD'
- request.response.setBody(u"spam")
+ request.response.setResult(u"spam")
pub.afterCall(request, None)
self.assertEqual(request.response.testBody(), '')
def testUnicode_NO_HTTP_CHARSET(self):
# Test so that a unicode body doesn't cause a UnicodeEncodeError
- output = StringIO()
- request = TestRequest(StringIO(''), output, {})
- request.response.setBody(u"\u0442\u0435\u0441\u0442")
- request.response.outputBody()
+ request = TestRequest(StringIO(''), {})
+ request.response.setResult(u"\u0442\u0435\u0441\u0442")
+ headers = request.response.getHeaders()
+ headers.sort()
self.assertEqual(
- output.getvalue(),
- 'Status: 200 Ok\r\n'
- 'Content-Length: 8\r\n'
- 'Content-Type: text/plain;charset=utf-8\r\n'
- 'X-Content-Type-Warning: guessed from content\r\n'
- 'X-Powered-By: Zope (www.zope.org), Python (www.python.org)\r\n'
- '\r\n\xd1\x82\xd0\xb5\xd1\x81\xd1\x82')
+ headers,
+ [('Content-Length', '8'),
+ ('Content-Type', 'text/plain;charset=utf-8'),
+ ('X-Content-Type-Warning', 'guessed from content'),
+ ('X-Powered-By', 'Zope (www.zope.org), Python (www.python.org)')])
+ self.assertEqual(
+ ''.join(request.response.result.body),
+ '\xd1\x82\xd0\xb5\xd1\x81\xd1\x82')
class HTTPPublicationRequestFactoryTests(BasePublicationTests):
def testGetBackSamePublication(self):
factory = HTTPPublicationRequestFactory(db=None)
- args = (None, None, {})
+ args = (None, {})
self.assert_(id(factory(*args).publication) ==
id(factory(*args).publication))
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_http.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_http.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_http.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -47,7 +47,7 @@
def test_callObject(self):
pub = zope.app.publication.http.HTTPPublication(None)
- request = HTTPRequest(StringIO(''), StringIO(), {})
+ request = HTTPRequest(StringIO(''), {})
request.method = 'SPAM'
ztapi.provideView(I, IHTTPRequest, Interface, 'SPAM', V)
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_httpfactory.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_httpfactory.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_httpfactory.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -78,34 +78,32 @@
env['REQUEST_METHOD'] = 'POST'
env['CONTENT_TYPE'] = 'text/xml'
input = StringIO('')
- output = StringIO()
env['HTTP_SOAPACTION'] = 'foo'
- self.assertEqual(httpfactory(input, output, env), soaprequestfactory)
+ self.assertEqual(httpfactory(input, env), soaprequestfactory)
del env['HTTP_SOAPACTION']
- self.assertEqual(httpfactory(input, output, env), xmlrpcrequestfactory)
+ self.assertEqual(httpfactory(input, env), xmlrpcrequestfactory)
env['CONTENT_TYPE'] = 'text/foo'
self.assertEqual(
- httpfactory(input, output, env), browserrequestfactory)
+ httpfactory(input, env), browserrequestfactory)
env['REQUEST_METHOD'] = 'FLOO'
- self.assertEqual(httpfactory(input, output, env), httprequestfactory)
+ self.assertEqual(httpfactory(input, env), httprequestfactory)
def test_browser(self):
- r = self.__factory(StringIO(''), StringIO(), self.__env)
+ r = self.__factory(StringIO(''), self.__env)
self.assertEqual(r.__class__, BrowserRequest)
self.assertEqual(r.publication.__class__, BrowserPublication)
for method in ('GET', 'HEAD', 'POST', 'get', 'head', 'post'):
self.__env['REQUEST_METHOD'] = method
- r = self.__factory(StringIO(''), StringIO(), self.__env)
+ r = self.__factory(StringIO(''), self.__env)
self.assertEqual(r.__class__, BrowserRequest)
self.assertEqual(r.publication.__class__, BrowserPublication)
-
def test_http(self):
for method in ('PUT', 'put', 'ZZZ'):
self.__env['REQUEST_METHOD'] = method
- r = self.__factory(StringIO(''), StringIO(), self.__env)
+ r = self.__factory(StringIO(''), self.__env)
self.assertEqual(r.__class__, HTTPRequest)
self.assertEqual(r.publication.__class__, HTTPPublication)
@@ -113,26 +111,23 @@
self.__env['CONTENT_TYPE'] = 'text/xml'
for method in ('POST', 'post'):
self.__env['REQUEST_METHOD'] = method
- r = self.__factory(StringIO(''), StringIO(), self.__env)
+ r = self.__factory(StringIO(''), self.__env)
self.assertEqual(r.__class__, XMLRPCRequest)
self.assertEqual(r.publication.__class__, XMLRPCPublication)
-
# content type doesn't matter for non post
for method in ('GET', 'HEAD', 'get', 'head'):
self.__env['REQUEST_METHOD'] = method
- r = self.__factory(StringIO(''), StringIO(), self.__env)
+ r = self.__factory(StringIO(''), self.__env)
self.assertEqual(r.__class__, BrowserRequest)
self.assertEqual(r.publication.__class__, BrowserPublication)
for method in ('PUT', 'put', 'ZZZ'):
self.__env['REQUEST_METHOD'] = method
- r = self.__factory(StringIO(''), StringIO(), self.__env)
+ r = self.__factory(StringIO(''), self.__env)
self.assertEqual(r.__class__, HTTPRequest)
self.assertEqual(r.publication.__class__, HTTPPublication)
-
-
def test_suite():
return TestSuite((
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_zopepublication.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/tests/test_zopepublication.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -131,8 +131,7 @@
ztapi.provideNamespaceHandler('resource', resource)
ztapi.provideNamespaceHandler('etc', etc)
- self.out = StringIO()
- self.request = TestRequest('/f1/f2', outstream=self.out)
+ self.request = TestRequest('/f1/f2')
self.user = Principal('test.principal')
self.request.setPrincipal(self.user)
from zope.interface import Interface
@@ -169,8 +168,7 @@
pass
self.publication.handleException(
self.object, self.request, sys.exc_info(), retry_allowed=False)
- self.request.response.outputBody()
- value = self.out.getvalue().split()
+ value = ''.join(self.request.response.result).split()
self.assertEqual(' '.join(value[:6]),
'Traceback (most recent call last): File')
self.assertEqual(' '.join(value[-8:]),
@@ -194,8 +192,7 @@
pass
self.publication.handleException(
self.object, self.request, sys.exc_info(), retry_allowed=False)
- self.request.response.outputBody()
- self.assertEqual(self.out.getvalue(), view_text)
+ self.assertEqual(''.join(self.request.response.result), view_text)
def testHandlingSystemErrors(self):
@@ -204,7 +201,7 @@
from zope.testing import loggingsupport
handler = loggingsupport.InstalledHandler('SiteError')
-
+
self.testViewOnException()
self.assertEqual(
@@ -216,13 +213,11 @@
# installed an error reporting utility. That's OK.
handler.uninstall()
- self.out.seek(0)
- self.out.truncate(0)
handler = loggingsupport.InstalledHandler('SiteError')
# Now, we'll register an exception view that indicates that we
# have a system error.
-
+
from zope.interface import Interface, implements
class E2(Exception):
pass
@@ -240,10 +235,10 @@
def isSystemError(self):
return True
-
+
def __call__(self):
return view_text
-
+
ztapi.provideView(E2, self.presentation_type, Interface,
'name', MyView)
try:
@@ -251,7 +246,6 @@
except:
self.publication.handleException(
self.object, self.request, sys.exc_info(), retry_allowed=False)
- self.request.response.outputBody()
# Now, since the view was a system error view, we should have
# a log entry for the E2 error (as well as the missing
@@ -284,11 +278,10 @@
pass
self.publication.handleException(
self.object, self.request, sys.exc_info(), retry_allowed=False)
- self.request.response.outputBody()
# check we don't get the view we registered
- self.failIf(self.out.getvalue() == view_text)
+ self.failIf(''.join(self.request.response.result) == view_text)
# check we do actually get something
- self.failIf(self.out.getvalue() == '')
+ self.failIf(''.join(self.request.response.result) == '')
def testExceptionSideEffects(self):
from zope.publisher.interfaces import IExceptionSideEffects
@@ -351,7 +344,7 @@
self.publication.handleException(
self.object, self.request, sys.exc_info(), retry_allowed=False)
# assert that we get a new transaction
- self.assert_(txn is not transaction.get())
+ self.assert_(txn is not transaction.get())
def testAbortTransactionWithErrorReportingUtility(self):
# provide our fake error reporting utility
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/zopepublication.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publication/zopepublication.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -320,7 +320,7 @@
# arguments. The positional arguments were meant
# for the published object, not an exception view.
body = mapply(view, (), request)
- response.setBody(body)
+ response.setResult(body)
transaction.commit()
if (ISystemErrorView.providedBy(view)
and view.isSystemError()):
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/__init__.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/__init__.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/recorder/__init__.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -27,7 +27,7 @@
from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
from zope.app.server.servertype import ServerType
from zope.server.http.commonaccesslogger import CommonAccessLogger
-from zope.server.http.publisherhttpserver import PublisherHTTPServer
+from zope.server.http.wsgihttpserver import WSGIHTTPServer
from zope.server.http.httpserverchannel import HTTPServerChannel
from zope.server.http.httprequestparser import HTTPRequestParser
from zope.server.http.httptask import HTTPTask
@@ -88,7 +88,7 @@
parser_class = RecordingHTTPRequestParser
-class RecordingHTTPServer(PublisherHTTPServer):
+class RecordingHTTPServer(WSGIHTTPServer):
"""Zope Publisher-specific HTTP server that can record requests."""
channel_class = RecordingHTTPServerChannel
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/configure.zcml
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/configure.zcml 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/configure.zcml 2005-09-07 17:41:06 UTC (rev 38346)
@@ -1,30 +1,38 @@
<configure xmlns="http://namespaces.zope.org/zope">
- <utility
+ <utility
component=".servercontrol.serverControl"
provides="zope.app.applicationcontrol.interfaces.IServerControl" />
<utility
- name="HTTP"
- component=".http.http"
+ name="WSGI-HTTP"
+ component=".wsgi.http"
provides=".servertype.IServerType"
/>
<utility
- name="PostmortemDebuggingHTTP"
- component=".http.pmhttp"
+ name="WSGI-PostmortemDebuggingHTTP"
+ component=".wsgi.pmhttp"
provides=".servertype.IServerType"
/>
<utility
- name="WSGI-HTTP"
+ name="FTP"
+ component=".ftp.server"
+ provides=".servertype.IServerType"
+ />
+
+ <!-- BBB: An alias kept around until Zope 3.4 -->
+ <utility
+ name="HTTP"
component=".wsgi.http"
provides=".servertype.IServerType"
/>
+ <!-- BBB: An alias kept around until Zope 3.4 -->
<utility
- name="FTP"
- component=".ftp.server"
+ name="PostmortemDebuggingHTTP"
+ component=".wsgi.pmhttp"
provides=".servertype.IServerType"
/>
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/ftp.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/ftp.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/ftp.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -28,13 +28,12 @@
FTP request factories for a given database create FTP requets with
publications on the given database:
-
+
>>> from ZODB.tests.util import DB
>>> db = DB()
>>> factory = FTPRequestFactory(db)
>>> from cStringIO import StringIO
- >>> request = factory(StringIO(''), StringIO(),
- ... {'credentials': None, 'path': '/'})
+ >>> request = factory(StringIO(''), {'credentials': None, 'path': '/'})
>>> request.publication.db is db
True
>>> db.close()
@@ -45,8 +44,8 @@
def __init__(self, db):
self.publication = FTPPublication(db)
- def __call__(self, input_stream, output_steam, env):
- request = FTPRequest(input_stream, output_steam, env)
+ def __call__(self, input_stream, env):
+ request = FTPRequest(input_stream, env)
request.setPublication(self.publication)
return request
Deleted: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/http.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/http.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/http.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -1,33 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (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.
-#
-##############################################################################
-"""HTTP server factories
-
-$Id$
-"""
-
-from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
-from zope.app.server.servertype import ServerType
-from zope.server.http.commonaccesslogger import CommonAccessLogger
-from zope.server.http.publisherhttpserver import PMDBHTTPServer
-from zope.server.http.publisherhttpserver import PublisherHTTPServer
-
-http = ServerType(PublisherHTTPServer,
- HTTPPublicationRequestFactory,
- CommonAccessLogger,
- 8080, True)
-
-pmhttp = ServerType(PMDBHTTPServer,
- HTTPPublicationRequestFactory,
- CommonAccessLogger,
- 8013, True)
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/wsgi.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/wsgi.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/server/wsgi.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -19,7 +19,7 @@
import zope.interface
from zope.server.http.commonaccesslogger import CommonAccessLogger
-from zope.server.http.wsgihttpserver import WSGIHTTPServer
+from zope.server.http import wsgihttpserver
from zope.app.wsgi import WSGIPublisherApplication
@@ -61,7 +61,12 @@
)
-http = ServerType(WSGIHTTPServer,
+http = ServerType(wsgihttpserver.WSGIHTTPServer,
WSGIPublisherApplication,
CommonAccessLogger,
8080, True)
+
+pmhttp = ServerType(wsgihttpserver.PMDBWSGIHTTPServer,
+ WSGIPublisherApplication,
+ CommonAccessLogger,
+ 8013, True)
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/http.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/http.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/http.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -90,15 +90,15 @@
This creates one if necessary:
>>> from zope.publisher.http import HTTPRequest
- >>> request = HTTPRequest(None, None, {}, None)
+ >>> request = HTTPRequest(None, {}, None)
>>> bim = CookieClientIdManager()
>>> id = bim.getClientId(request)
>>> id == bim.getClientId(request)
True
The id is retained accross requests:
-
- >>> request2 = HTTPRequest(None, None, {}, None)
+
+ >>> request2 = HTTPRequest(None, {}, None)
>>> request2._cookies = dict(
... [(name, cookie['value'])
... for (name, cookie) in request.response._cookies.items()
@@ -142,13 +142,13 @@
def getRequestId(self, request):
"""Return the browser id encoded in request as a string
-
+
Return None if an id is not set.
For example:
>>> from zope.publisher.http import HTTPRequest
- >>> request = HTTPRequest(None, None, {}, None)
+ >>> request = HTTPRequest(None, {}, None)
>>> bim = CookieClientIdManager()
Because no cookie has been set, we get no id:
@@ -169,7 +169,7 @@
When we set the request id, we also set a response cookie. We
can simulate getting this cookie back in a subsequent request:
- >>> request2 = HTTPRequest(None, None, {}, None)
+ >>> request2 = HTTPRequest(None, {}, None)
>>> request2._cookies = dict(
... [(name, cookie['value'])
... for (name, cookie) in request.response._cookies.items()
@@ -210,7 +210,7 @@
invalid value is silently ignored:
>>> from zope.publisher.http import HTTPRequest
- >>> request = HTTPRequest(None, None, {}, None)
+ >>> request = HTTPRequest(None, {}, None)
>>> bim = CookieClientIdManager()
>>> bim.getRequestId(request)
>>> bim.setRequestId(request, 'invalid id')
@@ -233,7 +233,7 @@
Expiry time of 0 means never (well - close enough)
>>> bim.cookieLifetime = 0
- >>> request = HTTPRequest(None, None, {}, None)
+ >>> request = HTTPRequest(None, {}, None)
>>> bid = bim.getClientId(request)
>>> cookie = request.response.getCookie(bim.namespace)
>>> cookie['expires']
@@ -242,7 +242,7 @@
A non-zero value means to expire after than number of seconds:
>>> bim.cookieLifetime = 3600
- >>> request = HTTPRequest(None, None, {}, None)
+ >>> request = HTTPRequest(None, {}, None)
>>> bid = bim.getClientId(request)
>>> cookie = request.response.getCookie(bim.namespace)
>>> import rfc822
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/session.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/session.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/session.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -49,7 +49,7 @@
class ClientId(str):
"""See zope.app.interfaces.utilities.session.IClientId
-
+
>>> import tests
>>> request = tests.setUp()
@@ -93,7 +93,7 @@
To ensure stale data is removed, we can wind
back the clock using undocumented means...
-
+
>>> sd.lastAccessTime = sd.lastAccessTime - 64
>>> sdc._v_last_sweep = sdc._v_last_sweep - 4
@@ -104,7 +104,7 @@
[...]
KeyError: 'clientid'
- Ensure lastAccessTime on the ISessionData is being updated
+ Ensure lastAccessTime on the ISessionData is being updated
occasionally. The ISessionDataContainer maintains this whenever
the ISessionData is set or retrieved.
@@ -182,7 +182,7 @@
def sweep(self):
"""Clean out stale data
-
+
>>> sdc = PersistentSessionDataContainer()
>>> sdc['1'] = SessionData()
>>> sdc['2'] = SessionData()
@@ -219,8 +219,8 @@
class RAMSessionDataContainer(PersistentSessionDataContainer):
"""A SessionDataContainer that stores data in RAM.
-
- Currently session data is not shared between Zope clients, so
+
+ Currently session data is not shared between Zope clients, so
server affinity will need to be maintained to use this in a ZEO cluster.
>>> sdc = RAMSessionDataContainer()
@@ -268,11 +268,11 @@
def __getitem__(self, pkg_id):
"""See zope.app.session.interfaces.ISession
-
+
>>> import tests
>>> request = tests.setUp(PersistentSessionDataContainer)
- >>> request2 = tests.HTTPRequest(None, None, {}, None)
-
+ >>> request2 = tests.HTTPRequest(None, {}, None)
+
>>> ISession.providedBy(Session(request))
True
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/tests.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/tests.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/session/tests.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -47,7 +47,7 @@
sdc = session_data_container_class()
for product_id in ('', 'products.foo', 'products.bar', 'products.baz'):
ztapi.provideUtility(ISessionDataContainer, sdc, product_id)
- request = HTTPRequest(None, None, {}, None)
+ request = HTTPRequest(None, {}, None)
return request
def tearDown():
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:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/browser.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -730,7 +730,7 @@
class BBBResponse(BrowserResponse):
def testBody(self):
- return self._body
+ return ''.join(self.result.body)
def outputBody(self):
import warnings
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/publication.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/publication.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/publication.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -54,7 +54,7 @@
def handleException(self, object, request, exc_info, retry_allowed=1):
'''See interface IPublication'''
try:
- request.response.setBody("%s: %s" % (exc_info[:2]))
+ request.response.setResult("%s: %s" % (exc_info[:2]))
finally:
exc_info = 0
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_baserequest.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_baserequest.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_baserequest.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -43,10 +43,10 @@
def test_IApplicationRequest_body(self):
from zope.publisher.base import BaseRequest
- request = BaseRequest(StringIO('spam'), StringIO(), {})
+ request = BaseRequest(StringIO('spam'), {})
self.assertEqual(request.body, 'spam')
- request = BaseRequest(StringIO('spam'), StringIO(), {})
+ request = BaseRequest(StringIO('spam'), {})
self.assertEqual(request.bodyFile.read(), 'spam')
def test_IPublicationRequest_getPositionalArguments(self):
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_baseresponse.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_baseresponse.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_baseresponse.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -26,7 +26,7 @@
class TestBaseResponse(TestCase):
def test_interface(self):
- verifyObject(IResponse, BaseResponse(StringIO()))
+ verifyObject(IResponse, BaseResponse())
def test_suite():
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_browserrequest.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_browserrequest.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_browserrequest.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -111,17 +111,15 @@
self.app.folder.item2 = Item2()
self.app.folder.item3 = Item3()
- def _createRequest(self, extra_env={}, body="", outstream=None):
+ def _createRequest(self, extra_env={}, body=""):
env = self._testEnv.copy()
env.update(extra_env)
if len(body):
env['CONTENT_LENGTH'] = str(len(body))
publication = Publication(self.app)
- if outstream is None:
- outstream = StringIO()
instream = StringIO(body)
- request = TestBrowserRequest(instream, outstream, env)
+ request = TestBrowserRequest(instream, env)
request.setPublication(publication)
return request
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_browserresponse.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_browserresponse.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_browserresponse.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -18,16 +18,15 @@
from unittest import TestCase, TestSuite, main, makeSuite
from zope.publisher.browser import BrowserResponse
-from StringIO import StringIO
from zope.interface.verify import verifyObject
# TODO: Waaa need more tests
class TestBrowserResponse(TestCase):
- def test_contentType_DWIM_in_setBody(self):
- response = BrowserResponse(StringIO())
- response.setBody(
+ def test_contentType_DWIM_in_setResult(self):
+ response = BrowserResponse()
+ response.setResult(
"""<html>
<blah>
</html>
@@ -35,8 +34,8 @@
self.assert_(response.getHeader('content-type').startswith("text/html")
)
- response = BrowserResponse(StringIO())
- response.setBody(
+ response = BrowserResponse()
+ response.setResult(
"""<html foo="1"
bar="x">
<blah>
@@ -45,8 +44,8 @@
self.assert_(response.getHeader('content-type').startswith("text/html")
)
- response = BrowserResponse(StringIO())
- response.setBody(
+ response = BrowserResponse()
+ response.setResult(
"""<html foo="1"
bar="x">
<blah>
@@ -55,8 +54,8 @@
self.assert_(response.getHeader('content-type').startswith("text/html")
)
- response = BrowserResponse(StringIO())
- response.setBody(
+ response = BrowserResponse()
+ response.setResult(
"""<!doctype html>
<html foo="1"
bar="x">
@@ -66,16 +65,16 @@
self.assert_(response.getHeader('content-type').startswith("text/html")
)
- response = BrowserResponse(StringIO())
- response.setBody(
+ response = BrowserResponse()
+ response.setResult(
"""Hello world
""")
self.assert_(response.getHeader('content-type').startswith(
"text/plain")
)
- response = BrowserResponse(StringIO())
- response.setBody(
+ response = BrowserResponse()
+ response.setResult(
"""<p>Hello world
""")
self.assert_(
@@ -86,7 +85,7 @@
from zope.publisher.interfaces.http import IHTTPResponse
from zope.publisher.interfaces.http import IHTTPApplicationResponse
from zope.publisher.interfaces import IResponse
- rp = BrowserResponse(StringIO())
+ rp = BrowserResponse()
verifyObject(IHTTPResponse, rp)
verifyObject(IHTTPApplicationResponse, rp)
verifyObject(IResponse, rp)
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_ftp.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_ftp.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_ftp.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -24,20 +24,16 @@
def setUp(self):
self.__input = StringIO('')
- self.__output = StringIO()
env = {'credentials': ('bob', '123'),
'path': '/a/b/c',
'command': 'foo',
}
- self.__request = zope.publisher.ftp.FTPRequest(
- self.__input, self.__output, env)
+ self.__request = zope.publisher.ftp.FTPRequest(self.__input, env)
def test_response(self):
response = self.__request.response
- response.setBody(123.456)
- response.outputBody()
+ response.setResult(123.456)
self.assertEqual(response.getResult(), 123.456)
- self.failIf(self.__output.getvalue())
try:
raise ValueError('spam')
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_http.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_http.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_http.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -80,17 +80,15 @@
self.app.folder.item = Item()
self.app.xxx = Item()
- def _createRequest(self, extra_env={}, body="", outstream=None):
+ def _createRequest(self, extra_env={}, body=""):
env = self._testEnv.copy()
env.update(extra_env)
if len(body):
env['CONTENT_LENGTH'] = str(len(body))
publication = DefaultPublication(self.app)
- if outstream is None:
- outstream = StringIO()
instream = StringIO(body)
- request = HTTPRequest(instream, outstream, env)
+ request = HTTPRequest(instream, env)
request.setPublication(publication)
return request
@@ -285,13 +283,7 @@
self.assertEquals(lpw, (login, password))
def testSetPrincipal(self):
- class HTTPTaskStub(object):
- auth_user_name = None
- def setAuthUserName(self, name):
- self.auth_user_name = name
-
- task = HTTPTaskStub()
- req = self._createRequest(outstream=task)
+ req = self._createRequest()
req.setPrincipal(UserStub("jim"))
self.assertEquals(req.response.authUser, 'jim')
@@ -423,7 +415,7 @@
class TestHTTPResponse(unittest.TestCase):
def testInterface(self):
- rp = HTTPResponse(StringIO())
+ rp = HTTPResponse()
verifyObject(IHTTPResponse, rp)
verifyObject(IHTTPApplicationResponse, rp)
verifyObject(IResponse, rp)
@@ -441,7 +433,7 @@
if headers is not None:
for hdr, val in headers.iteritems():
response.setHeader(hdr, val)
- response.setBody(body)
+ response.setResult(body)
return self._parseResult(response)
def testWrite_noContentLength(self):
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_ipublication.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_ipublication.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_ipublication.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -48,7 +48,7 @@
def _Test__request(self):
from zope.publisher.base import BaseRequest
- request = BaseRequest(StringIO(''), StringIO(), {})
+ request = BaseRequest(StringIO(''), {})
request.setTraversalStack(['Engineering', 'ZopeCorp'])
publication = self._Test__new()
request.setPublication(publication)
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_xmlrpcrequest.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_xmlrpcrequest.py 2005-09-07 16:39:21 UTC (rev 38345)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/tests/test_xmlrpcrequest.py 2005-09-07 17:41:06 UTC (rev 38346)
@@ -104,17 +104,15 @@
self.app.folder.item2 = Item2()
- def _createRequest(self, extra_env={}, body="", outstream=None):
+ def _createRequest(self, extra_env={}, body=""):
env = self._testEnv.copy()
env.update(extra_env)
if len(body):
env['CONTENT_LENGTH'] = str(len(body))
publication = Publication(self.app)
- if outstream is None:
- outstream = StringIO()
instream = StringIO(body)
- request = TestXMLRPCRequest(instream, outstream, env)
+ request = TestXMLRPCRequest(instream, env)
request.setPublication(publication)
return request
More information about the Zope3-Checkins
mailing list