XML file backend

Phil Longstaff plongstaff at rogers.com
Tue Jun 10 08:42:30 EDT 2008

The xml file backend has 2 functions to handle a commodity reference.  The first, dom_tree_to_commodity_ref_no_engine(), gets the two pieces of the reference (space and id) and creates a new gnc_commodity from them.  The second, dom_tree_to_commodity_ref(), calls dom_tree_to_commodity_ref_no_engine() and then looks up the commodity in the engine.  This has the result of only leaving 1 gnc_commodity per commodity.

In the places where commodity refs are used, dom parsers for prices and transactions call dom_tree_to_commodity_ref() but the parser for accounts calls dom_tree_to_commodity_ref_no_engine().  Can anyone explain why?

In the sql backend, this is causing problems for scheduled transactions and template accounts/commodities.  The xml file has template commodities with space/id = template/template.  When the xml file is loaded, dom_tree_to_commodity_ref_no_engine() creates 1 template commodity per template account, each with its own guid.  When saved to an sqlite file, there is still 1 template commodity per template account.  However, when I load the commodities from an sqlite file, I need to force the guids (for currencies for example) to be what the sqlite file expects to them to be.  I do this by calling gnc_commodity_lookup() and then changing the commodity guid.  This is fine for currencies, but for template commodities, I end up with 1 template commodity with the last guid in the file and all of the other template commodities are thrown away and the references in the template accounts are invalid.

Josh, does the sx code need a separate template commodity per account?  Should the account xml parser use dom_tree_to_commodity_ref() to merge these?  Should the sql backends only merge currencies, not any other commodities?


More information about the gnucash-devel mailing list