[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/file/browser/image.py Simplify how the image size display is generated for the Upload tab.

Fred L. Drake, Jr. fred at zope.com
Thu Jul 1 17:34:32 EDT 2004


Log message for revision 26038:
Simplify how the image size display is generated for the Upload tab.

This re-uses the existing display support from ImageSized, so takes
advantage of any localization of the messages provided for that.

Closes collector issue 218.



-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/file/browser/image.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/file/browser/image.py	2004-07-01 21:29:51 UTC (rev 26037)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/file/browser/image.py	2004-07-01 21:34:32 UTC (rev 26038)
@@ -15,7 +15,9 @@
 
 $Id$
 """
+from zope.app import zapi
 from zope.app.size import byteDisplay
+from zope.app.size.interfaces import ISized
 
 class ImageData(object):
 
@@ -85,11 +87,5 @@
     """Image edit view mix-in that provides access to image size info"""
 
     def size(self):
-        sx, sy = self.context.getImageSize()
-        if sx < 0:
-            sx = '?'
-        if sy < 0:
-            sy = '?'
-        return "%s x %s pixels, %s" % (
-                sx, sy, byteDisplay(self.context.getSize())
-                )
+        sized = zapi.getAdapter(self.context, ISized)
+        return sized.sizeForDisplay()



More information about the Zope3-Checkins mailing list