+def currency(name, value, *args, **kwargs):
+ if 'class_' not in kwargs:
+ kwargs['class_'] = ''
+ kwargs['class_'] += 'currency'
+ value = "%0.2f" % (int(value) / 100.)
+ return text(name, value, *args, **kwargs)
+
+
+def grab(obj, attr):
+ if obj:
+ return getattr(obj, attr)
+ else:
+ if attr == 'date':
+ return date.today()
+ elif attr in ('spender_id', 'creditor_id', 'debtor_id'):
+ return request.environ['user'].id
+ elif attr == 'amount':
+ return 0
+ else:
+ return ''