Working example of kvp acess in Python
c.holtermann at gmx.de
Fri Nov 14 13:47:07 EST 2014
Am 13.11.2014 um 19:56 schrieb John Ralls:
> On Nov 13, 2014, at 10:46 AM, Christoph Holtermann <c.holtermann at gmx.de> wrote:
>> Am 13.11.2014 um 18:55 schrieb Christoph Holtermann:
>>> Am 13.11.2014 um 17:50 schrieb Christian Stimming (mobil):
>>>> From my understanding, there are two separate issues here:
>>>> 1. You are proposing a new object "Company" because you have reasons for needing new data fields. I think that's a good idea. Why don't you prepare a patch to extend the existing objects?
>>>> 2. You ask for kvp access from python. No, we prefer not to have kvp accessed from python. Instead, either use gobject properties (on master), or add a new object on the C side as mentioned above and add python wrappers for this.
>>> Surely adding an object on the C side would be the more robust approach. Can you tell me an object that already exists
>>> and that could be taken as an example ?
>> I'll try gncAddress as a start.
>>> I don't really understand the gobject concept though and what the difference to my approach is.
>>> It seems some work until we have something we're all happy with, though ;-)
> You needn't worry about GObject. We’re replacing it with C++, but we’re just starting out and it will be several months at least before we’re ready to start on the engine objects. If you must dive in now, sure, GncAddress should be a pretty good starting point, but I suggest reading up a bit on GObject  so that you have some understanding of what you’re doing. In particular, the memory management parts of almost all of the GObject-based classes in engine, including GncAddress, are implemented incorrectly. Make sure that you understand the right way to create and in particular destroy (the functions for the latter are dispose and finalize) your object and to use reference counting correctly to manage object lifetime.
Having not yet looked at the GObject finetuning I wrote a gncCompany.c by modifying gncAddress.
It gets and sets the Companies information and can be accessed from Python.
First running version at https://github.com/c-holtermann/gnucash/compare/Company
Now I'll have to have the look at things that you suggested.
Maybe a dumb question, but anyway: Does the Company object need to store strings internally like Address does or can
the kvps be directly modified ? So do I need to have company->name etc. ?
> Your Company class implements only getters, which for your report-writing code is all that you need. The corresponding C/C++ class will need setters as well. In the current implementation where it writes to the QofBook KVP, that would be all.
> John Ralls
>  https://developer.gnome.org/gobject/stable/
--- 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