Working example of kvp acess in Python

Christoph Holtermann c.holtermann at
Thu Jun 12 17:17:32 EDT 2014

Am 10.06.2014 18:02, schrieb John Ralls:
> On Jun 10, 2014, at 8:24 AM, David Osguthorpe wrote:
>> On Mon, Jun 09, 2014 at 12:53:38AM +0200, Christoph Holtermann wrote:
>>> Hello,
>>> for my python latex invoice script I tried to access the owners data. I tried
>>> to work my way to it and came across the kvp system. I made a rude
>>> path through there with a working example to access the companies data.
>>> If someone is interested in clarifying the swig qof_instance and kvp_frame
>>> stuff for python it would be nice to cooperate.
>>> My branch on github about this is
>> Hi
>> I have been working with the python bindings but all my knowledge is from my human introspection
>> of the existing code
>> I have worked on adding the budget - as you have done you add the include files to the
>> swig interface file gnucash_core.i and most objects get a base swig interface
>> My analysis shows that the bindings then wrap the raw swig objects inside more pythonic classes
>> using GnuCashCoreClass as the base object
>> so eg in your your case you might want to define     class KvpFrame(GnuCashCoreClass):
>> you then add methods by calling the add_methods function
>> eg
>> KvpFrame.add_methods_with_prefix('kvp_frame_')
>> where any c function that starts with the string kvp_frame_ gets added to the class
>> This does add all methods that begin with this string - the only methods you can actually
>> use in the class though are those where the C kvpframe structure is the first argument
>> if methods return special objects the should use methods_return_instances
>> to add the return object type
>> I have messed a little with the Kvp stuff - one problem is that it tends to return multiple
>> types which is not so easy to handle - may have to follow the GList typemap as defined
>> in base-typemaps.i
> Note that in master, KVP is converted to a private implementation detail of the class that it's attached to, and once C++ conversion gets to the KVP-using classes it will probably get pushed even further down so that it's a persistence detail, existing only in the backends.
> In other words, any KVP code you write will break in the next version.
> Regards,
> John Ralls
Even now i find it a bit difficult to get to the kvp layer. I tried to get to the transactions kvps
( )
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 ?


Christoph Holtermann

--- Nachricht gesendet von C. Holtermann ---
-                                          -
-  Verschlüsselte Nachrichten können über  -
- den öffentlichen Schlüssel auf folgendem -
- Keyserver an mich gesendet werden:       -

More information about the gnucash-devel mailing list