[Zope-Checkins] CVS: Packages/OFS - DTMLMethod.py:1.80.44.5

Jens Vagelpohl jens at dataflake.org
Mon Jan 10 08:44:45 EST 2005


Update of /cvs-repository/Packages/OFS
In directory cvs.zope.org:/tmp/cvs-serv17899/lib/python/OFS

Modified Files:
      Tag: Zope-2_7-branch
	DTMLMethod.py 
Log Message:
- Fix blowups when attempting to cache DTML Methods using
  filestream_iterator-based caching


=== Packages/OFS/DTMLMethod.py 1.80.44.4 => 1.80.44.5 ===
--- Packages/OFS/DTMLMethod.py:1.80.44.4	Thu Jan  8 18:33:47 2004
+++ Packages/OFS/DTMLMethod.py	Mon Jan 10 08:44:15 2005
@@ -32,6 +32,7 @@
 from Cache import Cacheable
 from zExceptions import Forbidden
 from zExceptions.TracebackSupplement import PathTracebackSupplement
+from ZPublisher.Iterators import IStreamIterator
 
 _marker = []  # Create a new marker object.
 
@@ -102,6 +103,19 @@
         if not self._cache_namespace_keys:
             data = self.ZCacheable_get(default=_marker)
             if data is not _marker:
+                if ( IStreamIterator.isImplementedBy(data) and 
+                     RESPONSE is not None ):
+                    # This is a stream iterator and we need to set some
+                    # headers now before giving it to medusa
+                    if RESPONSE.headers.get('content-length', None) is None:
+                        RESPONSE.setHeader('content-length', len(data))
+
+                    if ( RESPONSE.headers.get('content-type', None) is None and
+                         RESPONSE.headers.get('Content-type', None) is None ):
+                        ct = ( self.__dict__.get('content_type', None) or 
+                               self.default_content_type )
+                        RESPONSE.setHeader('content-type', ct)
+
                 # Return cached results.
                 return data
 



More information about the Zope-Checkins mailing list