[GNC-dev] Python bindings: How to expose additional engine functions

Steve Brown <[email protected]>
Newsgroups gmane.comp.gnome.apps.gnucash.devel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.