Working example of kvp acess in Python

Christoph Holtermann c.holtermann at gmx.de
Wed Nov 12 12:46:03 EST 2014


Hello,

so KVPs should be accessed by objects they belong to and not from the outside.
Some questions:
* Is it legitimate to have KVP representation in Python at all or is this low-level und
should remain to the c-api ?
* The information that I'm interested in is the company data for invoices. As far as
I' ve seen there is just KVP access to that.
* It seems to me that there should be an object Company that is structured similar
to Customer and has an assigned object Address identical to Customer.
* When only the object should be able to access KVP, who is this object for the
company address ? At the moment it's book, I guess.
* I could create a python object Company and add getter functions that access the
KVPs. But it seems better to me to not introduce objects in python that do not exist
in c.
* On the other hand it can still be changed afterwards if an object is introduced in
c.

regards,

Christoph Holtermann

Am 12.06.2014 um 23:42 schrieb John Ralls:
> 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
>


-- 
--- Nachricht gesendet von C. Holtermann ---
-                                          -
-  Verschlüsselte Nachrichten können über  -
- den öffentlichen Schlüssel auf folgendem -
- Keyserver an mich gesendet werden:       -
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x4DD9CF0482B0620B





More information about the gnucash-devel mailing list