[GNC-dev] Python bindings: How to expose additional engine functions
Steve Brown
sbrown at opensat.com
Tue Jan 24 17:03:45 EST 2023
My use case is accessing owner name and address from a transaction.
The transaction is found by guid.
Exposing guid_from_string() was pretty straightforward as was GetLot()
and GetFirstAPARAcctSplit().
I also need GetOwnerFromTxn or GetOwnerFromLot. However, this and many
similar functions return the result through an argument and indicate
success or failure by returning a boolean. It's not clear whether there
is an general way with swig to deal with this other than adding a
wrapper to return the result and indicate failure by returning NULL.
Any recommendations?
I also noticed that there is a problem with gnc-
session.c:gnc_get_current_session() using the bindings. In the
executable, gnc_set_current_session() is called in gnc_file.c after
each qof_session_new(). But with the Python bindings, the swig-
generated code calls qof_session_new(). So, current_session isn't
initialized and the first call subtly creates a new session. I added a
gnc_set_current_session() call to qof_session_new() and that fixed
things for me . I don't think that's the best solution.
Thanks,
Steve
More information about the gnucash-devel
mailing list