[ZDP] BackTalk to Document The Zope Book (2.6 Edition)/Using Zope
Page Templates
webmaster at zope.org
webmaster at zope.org
Tue Nov 4 10:53:42 EST 2003
A comment to the paragraph below was recently added via http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ZPT.stx#2-66
---------------
There are a few cosmetic problems with the file library as it
stands. The size and date displays of the default content are very
pretty, but the values returned from Zope don't match the format
of the dummy content. Instead, they are "raw" numbers. You would
like the size of the files to be displayed in K or MB rather than
bytes. Here's a Python-based script that you can use for this::
## Script (Python) "file_size"
##
"""
Return a string describing the size of a file.
"""
bytes=context.getSize()
k=bytes/1024.0
mb=bytes/1048576.0
if mb > 1:
return "%.2f MB" % mb
if k > 1:
return "%d K" % k
return "%d bytes" % bytes
% Anonymous User - Nov. 4, 2003 10:53 am:
We are learning about TAL?
More information about the ZDP
mailing list