[Zope3-checkins]
SVN: Zope3/trunk/src/zope/app/applicationcontrol/browser/
support storages that can't report their size
Philipp von Weitershausen
philikon at philikon.de
Sat Jul 23 11:43:28 EDT 2005
Log message for revision 37393:
support storages that can't report their size
reuse zope.app.size.byteDisplay for displaying a size in bytes
as a localized string.
Changed:
U Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_zodbcontrol.py
U Zope3/trunk/src/zope/app/applicationcontrol/browser/zodbcontrol.py
-=-
Modified: Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_zodbcontrol.py
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_zodbcontrol.py 2005-07-23 15:19:52 UTC (rev 37392)
+++ Zope3/trunk/src/zope/app/applicationcontrol/browser/ftests/test_zodbcontrol.py 2005-07-23 15:43:27 UTC (rev 37393)
@@ -29,9 +29,8 @@
body = response.getBody()
self.assert_('value="3"' in body)
self.assert_('>Demo Storage</' in body)
- self.assert_('>100 Bytes</' in body)
+ self.assert_('>1 KB</' in body)
-
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ZODBControlTest))
Modified: Zope3/trunk/src/zope/app/applicationcontrol/browser/zodbcontrol.py
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/browser/zodbcontrol.py 2005-07-23 15:19:52 UTC (rev 37392)
+++ Zope3/trunk/src/zope/app/applicationcontrol/browser/zodbcontrol.py 2005-07-23 15:43:27 UTC (rev 37393)
@@ -19,6 +19,7 @@
from ZODB.FileStorage.FileStorage import FileStorageError
from zope.app.i18n import ZopeMessageIDFactory as _
+from zope.app.size import byteDisplay
class ZODBControlView(object):
@@ -29,19 +30,10 @@
def getSize(self):
"""Get the database size in a human readable format."""
size = self.request.publication.db.getSize()
- if size > 1024**2:
- size_str = _("${size} MB")
- size_str.mapping = {'size': "%.1f" %(float(size)/1024**2)}
- elif size > 1024:
- size_str = _("${size} kB")
- size_str.mapping = {'size': "%.1f" %(float(size)/1024)}
- else:
- size_str = _("${size} Bytes")
- size_str.mapping = {'size': "%i" %size}
+ if not isinstance(size, (int, long, float)):
+ return str(size)
+ return byteDisplay(size)
- return size_str
-
-
def pack(self):
"""Do the packing!"""
days = int(self.request.form.get('days', 0))
More information about the Zope3-Checkins
mailing list