__metaclass__ = SmartSubclass(int)
__old_values__ = WeakValueDictionary()
def __new__(cls, value):
- if isinstance(value, str):
+ if value is None:
+ value = 0
+ elif isinstance(value, str):
value = int(float(value) * 100)
else:
value = int(value)
"""
Get to the formatted string without the dollar sign
"""
- return str(self)[1:]
+ return str(self).replace('$', '')
def __repr__(self):
return '%s("%s")' % (self.__class__.__name__, str(self))
sign = '-' if self.value < 0 else ''
cents = abs(self.value) % 100
dollars = (abs(self.value) - cents) / 100
- return '$%s%s.%.02d' % (sign, dollars, cents)
+ return '%s$%s.%.02d' % (sign, dollars, cents)
class DBCurrency(sa.types.TypeDecorator):
"""
def convert_result_value(self, value, engine):
return Currency(value)
+ process_result_value = convert_result_value