[Zope-CMF] Re: [dev] Document.get_size considered dumb

Tres Seaver tseaver at zope.com
Wed Sep 29 09:55:44 EDT 2004


Florent Guillaume wrote:
> In article <cis3r9$oba$1 at sea.gmane.org> you write:
> 
>>I would like to modify the implementation of 
>>Products.CMFDefault.Document.get_size as follows:
>>
>>
>>--- CMFDefault/Document.py      7 Sep 2004 08:47:54 -0000       1.69.2.2
>>+++ CMFDefault/Document.py      22 Sep 2004 14:53:13 -0000
>>@@ -415,6 +415,6 @@
>>      security.declareProtected(View, 'get_size')
>>      def get_size( self ):
>>          """ Used for FTP and apparently the ZMI now too """
>>-        return len(self.manage_FTPget())
>>+        return len(self.text)
>>
>>  InitializeClass(Document)
>>
>>The current behavior tries to ensure that 'get_size' returns exactly the 
>>same value as the length of the decorated source text.  The only 
>>dependent I know of for that behavir is webdav's HEAD;  I have no 
>>problem with "breaking" that, because there is no guarantee that HEAD 
>>and GET will return the same values between two requests, anyway.
>>
>>Are there any other clients out there who care about 'get_size'?  If 
>>noone objects, I will check it in on Friday (I may make the size cached, 
>>as well).
> 
> 
> No pb with that.
> 
> As we've had requests from people about it, I'd like to confirm:
> get_size() is only used for "informative human-readble" values of the
> size, right ?
> 
> A use case we've had is for an objects that stores, for instance, a PDF
> file, but also internal full-text versions for the indexer and other
> things. The user expects to have get_size() return the size of the PDF,
> but in some cases (quota accounting) we'd like to have get_size() return
> the best approximation of the pickle size of the full object. So the
> question is: what size is it best to have get_size() return ?

The only current clients in the Zope core of 'get_size' are 
webdav.Resource's HEAD method (where it is used to emit the 
'Content-length' header) and the various bits of OFS stuff which treat 
it as a "content size" field (for uses like the CMF's 
'folder_contents').  I would declare another interface (IQuotaSize, or 
whatever), and use a different name for the "true" size.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com



More information about the Zope-CMF mailing list