pickle error

davidcullen's Avatar

davidcullen

22 Jul, 2019 03:07 AM

I'm trying to pickle a dictionary with contains many items, one of which is an Account. I'm getting an error: TypeError: can't pickle Account objects. Here is my code:

from com.infinitekind.moneydance.model import AccountUtil
import pickle
root = moneydance.getCurrentAccount()
account = root.getAccountByName("Cash on hand:USD cash")
with open('test.pkl', 'wb') as f:
    pickle.dump(account, f)
  1. Support Staff 1 Posted by Sean Reilly on 23 Jul, 2019 08:49 AM

    Sean Reilly's Avatar

    Hi David,
    Yes, I don't think it will be possible to pickle an Account object because Moneydance manages those objects, including associating them with an account book as well as managing and automatically saving changes. So Moneydance needs to be responsible for constructing, resolving, and avoiding duplication of accounts. Is what you want instead to do something like store a reference to an account that you can then use the AccountBook to locate that account?

    Thanks,
    Sean

    --
    Sean Reilly
    Developer, The Infinite Kind
    https://infinitekind.com

  2. 2 Posted by davidcullen on 24 Jul, 2019 04:06 AM

    davidcullen's Avatar

    Thanks Sean. Yes, I have made a "work around" along these lines and all now works ok.

  3. davidcullen closed this discussion on 24 Jul, 2019 04:06 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac