[Zope-Checkins] CVS: Zope/lib/python/OFS - Image.py:1.145.2.5.2.5

Chris McDonough chrism at plope.com
Sun Mar 28 05:27:27 EST 2004


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

Modified Files:
      Tag: chrism-publishfile-branch
	Image.py 
Log Message:
Dont refresh the cache on an IMS hit.

Allow manage_FTPget to consume caching services.

Cache stuff on update_data in Image class.



=== Zope/lib/python/OFS/Image.py 1.145.2.5.2.4 => 1.145.2.5.2.5 ===
--- Zope/lib/python/OFS/Image.py:1.145.2.5.2.4	Sun Mar 28 01:35:28 2004
+++ Zope/lib/python/OFS/Image.py	Sun Mar 28 05:27:27 2004
@@ -158,7 +158,6 @@
                     RESPONSE.setHeader('Content-Length', self.size)
                     RESPONSE.setHeader('Accept-Ranges', 'bytes')
                     RESPONSE.setStatus(304)
-                    self.ZCacheable_set(None)
                     return True
 
     def _range_request_handler(self, REQUEST, RESPONSE):
@@ -388,16 +387,16 @@
         RESPONSE.setHeader('Accept-Ranges', 'bytes')
 
         if self.ZCacheable_isCachingEnabled():
-            marker = []
             result = self.ZCacheable_get(default=None)
             if result is not None:
-                # We will always get None from RAMCacheManager but we will get
+                # We will always get None from RAMCacheManager and HTTP
+                # Accelerated Cache Manager but we will get
                 # something implementing the IStreamIterator interface
-                # from FileCacheManager.
+                # from a "FileCacheManager"
                 return result
-            
-        self.ZCacheable_set(None)
 
+        self.ZCacheable_set(None)
+            
         data=self.data
         if type(data) is type(''):
             RESPONSE.setBase(None) 
@@ -422,6 +421,7 @@
         if size is None: size=len(data)
         self.size=size
         self.data=data
+        self.ZCacheable_invalidate()
         self.ZCacheable_set(None)
         self.http__refreshEtag()
 
@@ -583,9 +583,18 @@
 
     def manage_FTPget(self):
         """Return body for ftp."""
+        if self.ZCacheable_isCachingEnabled():
+            result = self.ZCacheable_get(default=None)
+            if result is not None:
+                # We will always get None from RAMCacheManager but we will get
+                # something implementing the IStreamIterator interface
+                # from FileCacheManager.
+                # the content-length is required here by HTTPResponse, even
+                # though FTP doesn't use it.
+                self.REQUEST.RESPONSE.setHeader('Content-Length', self.size)
+                return result
         return str(self.data)
 
-
 manage_addImageForm=DTMLFile('dtml/imageAdd',globals(),
                              Kind='Image',kind='image')
 def manage_addImage(self, id, file, title='', precondition='', content_type='',
@@ -748,7 +757,7 @@
         if content_type is not None: self.content_type = content_type
 
         self.ZCacheable_invalidate()
-
+        self.ZCacheable_set(None)
 
     def __str__(self):
         return self.tag()




More information about the Zope-Checkins mailing list