diff --git a/CHANGES.rst b/CHANGES.rst index f8cb98df98..b500995ef6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,9 @@ Breaking changes: New features: +- Factored out format_size method for replacing getObjSize.py. #1801 + [reinhardt] + - Update TinyMCE to 4.7.13 [erral] diff --git a/Products/CMFPlone/CatalogTool.py b/Products/CMFPlone/CatalogTool.py index c972acf0cd..4c8cf8501d 100644 --- a/Products/CMFPlone/CatalogTool.py +++ b/Products/CMFPlone/CatalogTool.py @@ -219,17 +219,10 @@ def getObjPositionInParent(obj): SIZE_ORDER = ('GB', 'MB', 'KB') -@indexer(Interface) -def getObjSize(obj): - """ Helper method for catalog based folder contents. - """ +def format_size(size): + """ Get a human readable size string. """ smaller = SIZE_ORDER[-1] - if base_hasattr(obj, 'get_size'): - size = obj.get_size() - else: - size = 0 - # if the size is a float, then make it an int # happens for large files try: @@ -250,6 +243,18 @@ def getObjSize(obj): return size +@indexer(Interface) +def getObjSize(obj): + """ Helper method for catalog based folder contents. + """ + if base_hasattr(obj, 'get_size'): + size = obj.get_size() + else: + size = 0 + + return format_size(size) + + @indexer(Interface) def is_folderish(obj): """Should this item be treated as a folder?