BackTalk to Document The Zope Book (2.6 Edition)/Using Zope Page Templates

[email protected]
Newsgroups gmane.comp.web.zope.zdp
Message-ID <[email protected]>
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?

_______________________________________________
ZDP maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zdp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.