MonetaryType was a bad name for my example of what I was trying to do. I replaced it with FundingSource.
I forgot to include a field in the behavior, 'currency', which is used to store the currency type assigned to a funding source.
A FundingSource is assigned a currency (yen, pound, etc) based on what the user selects, but I need to convert the value entered of the funding source to USD.
Unfortunately, exchange rates aren't static. So we're storing the exchange rate between USD and the selected currency for the date the funding source was created.
Here's how I format the url I use to call the api (api.fixer.io):
currency = getattr(self, 'currency', 'USD')
date_of_creation = datetime.now().strftime('%Y-%m-%d')
api_uri = "http://api.fixer.io/{}?base={}&symbols={}".format(date_of_creation, currency, 'USD')
In the getExchangeRate function, I make this url and then make a request to get the exchange rate.
Since I don't want to abuse the api, I want to only use it when the funding source is created. I thought maybe making the exchange rate field readonly with defaultFactory set would've been a solution.
Edit: Actually, this probably a bad approach. In 'Edit': If they change the currency, I have to recalculate the exchange rate.
But still, I am curious why defaultFactory was firing when I wasn't even in a form.