[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container - contents.py:1.4 main.pt:1.3
Steve Alexander
steve@cat-box.net
Fri, 27 Dec 2002 10:23:21 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/container
In directory cvs.zope.org:/tmp/cvs-serv15314/src/zope/app/browser/container
Modified Files:
contents.py main.pt
Log Message:
implemented the size stuff from http://collector.zope.org/Zope3-dev/108
=== Zope3/src/zope/app/browser/container/contents.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/container/contents.py:1.3 Fri Dec 27 08:40:25 2002
+++ Zope3/src/zope/app/browser/container/contents.py Fri Dec 27 10:22:50 2002
@@ -15,13 +15,12 @@
Revision information: $Id$
"""
-from zope.app.interfaces.container import IContainer
-from zope.app.interfaces.container import IZopeContainer
+from zope.app.interfaces.container import IContainer, IZopeContainer
from zope.app.interfaces.dublincore import IZopeDublinCore
+from zope.app.interfaces.size import ISized
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.component import queryView, getView, queryAdapter, getAdapter
-from zope.proxy.context import ContextWrapper
+from zope.component import queryView, queryAdapter, getAdapter
from zope.publisher.browser import BrowserView
@@ -48,9 +47,7 @@
title = dc.title
if title:
info['title'] = title
-
- magnitude, label = getSize(obj)
- info['size'] = {'size':magnitude, 'label':label}
+
created = dc.created
if created is not None:
info['created'] = formatTime(created)
@@ -59,6 +56,9 @@
if modified is not None:
info['modified'] = formatTime(modified)
+ sized_adapter = queryAdapter(obj, ISized)
+ if sized_adapter is not None:
+ info['size'] = sized_adapter
return info
@@ -95,23 +95,3 @@
if hasattr(in_date, 'strftime'):
return in_date.strftime(format)
return undefined
-
-#SteveA recommneded that getSize return
-#a tuple (magnitude, (size, text_label))
-#this way we can sort things intelligibly
-#that don't have sizes.
-
-def getSize(obj):
- try:
- size=int(obj.getSize())
- except (AttributeError, ValueError):
- return (0, u'N/A')
-
- result = u''
- if size < 1024:
- result = "1 KB"
- elif size > 1048576:
- result = "%0.02f MB" % (size / 1048576.0)
- else:
- result = "%d KB" % (size / 1024.0)
- return (size, result)
=== Zope3/src/zope/app/browser/container/main.pt 1.2 => 1.3 ===
--- Zope3/src/zope/app/browser/container/main.pt:1.2 Wed Dec 25 09:12:29 2002
+++ Zope3/src/zope/app/browser/container/main.pt Fri Dec 27 10:22:50 2002
@@ -55,7 +55,7 @@
>foo</a>
</td>
<td><span tal:content="item/title|default"> </span></td>
- <td><span tal:content="item/size|default"> </span></td>
+ <td><span tal:content="item/size/sizeForDisplay"> </span></td>
<td><span tal:define="created item/created|default"
tal:content="created"> </span></td>
<td><span tal:define="modified item/modified|default"