[Checkins] SVN: zc.resourcelibrary/trunk/ update code to guess mime
type to match zope.publication trunk; prepare for 1.0.1 release.
Gary Poster
gary at zope.com
Fri Mar 7 11:22:31 EST 2008
Log message for revision 84533:
update code to guess mime type to match zope.publication trunk; prepare for 1.0.1 release.
Changed:
U zc.resourcelibrary/trunk/CHANGES.txt
U zc.resourcelibrary/trunk/setup.py
U zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
U zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/tests.py
-=-
Modified: zc.resourcelibrary/trunk/CHANGES.txt
===================================================================
--- zc.resourcelibrary/trunk/CHANGES.txt 2008-03-07 16:15:44 UTC (rev 84532)
+++ zc.resourcelibrary/trunk/CHANGES.txt 2008-03-07 16:22:31 UTC (rev 84533)
@@ -2,6 +2,17 @@
CHANGES
=======
+1.0.1 (2008-03-07)
+------------------
+
+Bugs fixed:
+
+- added the behavior from the standard Zope 3 response to guess that a body
+ that is not HTML without an explicit mimetype should have a
+ 'text/plain' mimetype. This means that, for instance, redirects with
+ a body of '' and no explicit content type will no longer cause an
+ exception in the resourcelibrary response code.
+
1.0.0 (2008-02-17)
------------------
Modified: zc.resourcelibrary/trunk/setup.py
===================================================================
--- zc.resourcelibrary/trunk/setup.py 2008-03-07 16:15:44 UTC (rev 84532)
+++ zc.resourcelibrary/trunk/setup.py 2008-03-07 16:22:31 UTC (rev 84533)
@@ -22,7 +22,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zc.resourcelibrary',
- version = '1.0dev',
+ version = '1.0.1',
author='Zope Corporation and Contributors',
author_email='zope3-dev at zope.org',
description='Post-rendering Resource Inclusion',
Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py 2008-03-07 16:15:44 UTC (rev 84532)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py 2008-03-07 16:22:31 UTC (rev 84533)
@@ -70,6 +70,10 @@
if content_type is None:
if isHTML(body):
content_type = 'text/html'
+ else:
+ content_type = 'text/plain'
+ self.setHeader('x-content-type-warning', 'guessed from content')
+ self.setHeader('content-type', content_type)
# check the content type disregarding parameters and case
if content_type and content_type.split(';', 1)[0].lower() in (
Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/tests.py
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/tests.py 2008-03-07 16:15:44 UTC (rev 84532)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/tests.py 2008-03-07 16:22:31 UTC (rev 84533)
@@ -22,6 +22,7 @@
import zope.interface
from zope.pagetemplate import pagetemplate
import zope.publisher.interfaces.browser
+from zope.testing import doctest
import doctest
import os
import unittest
@@ -93,6 +94,20 @@
request.response.setResult(html)
return request.response.consumeBody()
+#### tests ####
+
+def test_empty_body():
+ """
+ If a response body is not html, guess that it is text/plain. This
+ follows the behavior of zope.publication's trunk as of this writing.
+
+ >>> import zc.resourcelibrary.publication
+ >>> response = zc.resourcelibrary.publication.Response()
+ >>> response.setResult('')
+ >>> response.getHeader('content-type')
+ 'text/plain'
+ """
+
#### test setup ####
ResourceLibraryFunctionalLayer = functional.ZCMLLayer(
@@ -106,7 +121,10 @@
optionflags=doctest.NORMALIZE_WHITESPACE+doctest.ELLIPSIS,
)
suite.layer = ResourceLibraryFunctionalLayer
- return suite
+ return unittest.TestSuite((
+ suite,
+ doctest.DocTestSuite()
+ ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
More information about the Checkins
mailing list