provide default currency for FloatValue

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3315 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2009-03-31 09:13:59 +00:00
parent ee26ab3ff4
commit d82704e17e

View file

@ -1,3 +1,4 @@
#-*- coding: UTF-8 -*-
# #
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de # Copyright (c) 2009 Helmut Merz helmutm@cy55.de
# #
@ -118,12 +119,16 @@ class BaseObject(object):
class FloatValue(float): class FloatValue(float):
def __init__(self, value, decimals=2): def __init__(self, value, decimals=2, currency=u''):
self.decimals = decimals self.decimals = decimals
self.currency = currency
def __str__(self): def __str__(self):
format = '%%.%if' % self.decimals format = '%%.%if' % self.decimals
return (format % self).replace('.', ',') value = (format % self).replace('.', ',')
if self.currency:
value = value + ' ' + self.currency
return value
# utility functions # utility functions