[Checkins] SVN: zc.resourcelibrary/trunk/ when checking content type, take into account that it may be None

Thomas Lotze tl at gocept.com
Fri Dec 7 05:45:08 EST 2007


Log message for revision 82171:
  when checking content type, take into account that it may be None

Changed:
  U   zc.resourcelibrary/trunk/CHANGES.txt
  U   zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt
  U   zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py

-=-
Modified: zc.resourcelibrary/trunk/CHANGES.txt
===================================================================
--- zc.resourcelibrary/trunk/CHANGES.txt	2007-12-07 01:50:47 UTC (rev 82170)
+++ zc.resourcelibrary/trunk/CHANGES.txt	2007-12-07 10:45:07 UTC (rev 82171)
@@ -2,6 +2,11 @@
 CHANGES
 =======
 
+0.8.2 (2007-12-07)
+------------------
+
+- bug fix: when checking content type, take into account that it may be None
+
 0.8.1 (2007-12-05)
 ------------------
 

Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt	2007-12-07 01:50:47 UTC (rev 82170)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt	2007-12-07 10:45:07 UTC (rev 82171)
@@ -220,7 +220,17 @@
     ...     page, content_type='text/xml ; charset=utf-8')
     False
 
+The content type may also be None if it was never set, which of course doesn't
+count as HTML or XML either:
 
+    >>> from zc.resourcelibrary import publication
+    >>> from StringIO import StringIO
+    >>> request = publication.Request(body_instream=StringIO(''), environ={})
+    >>> request.response.setResult("This is not HTML text.")
+    >>> '/@@/my-lib/included.js' in request.response.consumeBody()
+    False
+
+
 Dependencies
 ------------
 

Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py	2007-12-07 01:50:47 UTC (rev 82170)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py	2007-12-07 10:45:07 UTC (rev 82171)
@@ -72,7 +72,7 @@
                 content_type = 'text/html'
 
         # check the content type disregarding parameters and case
-        if content_type.split(';', 1)[0].lower() in (
+        if content_type and content_type.split(';', 1)[0].lower() in (
             'text/html', 'text/xml'):
             #act on HTML and XML content only!
 



More information about the Checkins mailing list