Skip to content

Commit

Permalink
register a JSON encoder for the Money type
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Oct 27, 2017
1 parent 04d0398 commit cc1e5ee
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions liberapay/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import aspen
import aspen.http.mapping
from mangopay.utils import Money
import pando
from pando import json
from pando.algorithms.website import fill_response_with_output
Expand Down Expand Up @@ -40,6 +41,8 @@
# Configure renderers
# ===================

json.register_encoder(Money, lambda m: {'amount': str(m.amount), 'currency': m.currency})

website.renderer_default = 'unspecified' # require explicit renderer, to avoid escaping bugs

website.renderer_factories['csv_dump'] = csv_dump.Factory(website)
Expand Down

0 comments on commit cc1e5ee

Please sign in to comment.