Working example of kvp acess in Python

John Ralls jralls at ceridwen.us
Thu Jun 12 17:42:58 EDT 2014


On Jun 12, 2014, at 2:17 PM, Christoph Holtermann <c.holtermann at gmx.de> wrote:
>> 
> Even now i find it a bit difficult to get to the kvp layer. I tried to get to the transactions kvps
> ( https://github.com/c-holtermann/gnucash/commit/636631027d0f8833b3d1b7d8a8c1271ce5f8449e )
> and ended up writing a function xaccTransGetFrame.
> 
> If i get the frame object I'm happy at the moment. Is it intentional that you put it private and which is
> the intended way to get the kvps of an(y) object ?

Very intentional. Having object state that’s effectively invisible to the object is an incredibly bad design and is largely to blame for the data integrity problems we’ve had with the SQL backend.

On master you can access all of the KVP data using gobject properties. Qof_instance_get() and qof_instance_set() essentially wrap g_object_get and set; in the latter case qof_instance_set also marks the object dirty. Some items also have getter and setter functions; some of those do the change in an edit/commit block, so you might find it a useful optimization to wrap multiple calls in its own edit/commit so that it’s all done at once.

Regards,
John Ralls




More information about the gnucash-devel mailing list