[CMF-checkins] CVS: CMF/CMFCore - FSImage.py:1.10.30.1
Tres Seaver
tseaver@zope.com
Mon, 6 May 2002 14:01:54 -0400
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv29642
Modified Files:
Tag: CMF-1_3-branch
FSImage.py
Log Message:
- Remove repeated load of image from file (should only happen inside
'_updateFromFS'!)
=== CMF/CMFCore/FSImage.py 1.10 => 1.10.30.1 ===
meta_type = 'Filesystem Image'
+ _data = None
+
manage_options=(
{'label':'Customize', 'action':'manage_main'},
)
@@ -54,8 +56,10 @@
def _readFile(self, reparse):
fp = expandpath(self._filepath)
file = open(fp, 'rb')
- try: data = file.read()
- finally: file.close()
+ try:
+ data = self._data = file.read()
+ finally:
+ file.close()
if reparse or self.content_type == 'unknown/unknown':
ct, width, height = getImageInfo( data )
self.content_type = ct
@@ -83,7 +87,7 @@
Content-Type HTTP header to the objects content type.
"""
self._updateFromFS()
- data = self._readFile(0)
+ data = self._data
# HTTP If-Modified-Since header handling.
header=REQUEST.get_header('If-Modified-Since', None)
if header is not None:
@@ -103,7 +107,7 @@
# Content-Length of 0 in response if size is not set here
RESPONSE.setHeader('Last-Modified', rfc1123_date(last_mod))
RESPONSE.setHeader('Content-Type', self.content_type)
- RESPONSE.setHeader('Content-Length', self.get_size())
+ RESPONSE.setHeader('Content-Length', len(data))
RESPONSE.setStatus(304)
return ''
@@ -121,6 +125,14 @@
"""
self._updateFromFS()
return self.content_type
+
+ security.declareProtected(View, 'get_size')
+ def get_size( self ):
+ """
+ Return the size of the image.
+ """
+ self._updateFromFS()
+ return self._data and len( self._data ) or 0
security.declareProtected(FTPAccess, 'manage_FTPget')
manage_FTPget = index_html