From ee26ab3ff4a61293b1c1c7682c7cf5422264e9b3 Mon Sep 17 00:00:00 2001 From: helmutm Date: Mon, 30 Mar 2009 17:36:51 +0000 Subject: [PATCH] add class FloatValue for transparent number formatting' git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3312 fd906abe-77d9-0310-91a1-e0d9ade77398 --- commerce/common.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/commerce/common.py b/commerce/common.py index a5a1c78..26e2913 100644 --- a/commerce/common.py +++ b/commerce/common.py @@ -116,6 +116,16 @@ class BaseObject(object): collection = RelationSet +class FloatValue(float): + + def __init__(self, value, decimals=2): + self.decimals = decimals + + def __str__(self): + format = '%%.%if' % self.decimals + return (format % self).replace('.', ',') + + # utility functions def getUidForObject(obj, intIds=None):