Guile API

John Ralls jralls at ceridwen.us
Thu Oct 29 13:14:53 EDT 2015


> On Oct 29, 2015, at 8:04 AM, Alex Weiss <alexweiss at theplate.com> wrote:
> 
> I was considering scripting GnuCash using its Guile API rather that it's Python API?  Am I crazy to assume that the Guile API is as rich an the Python API? 
> 
> The first stumbling block I have noticed is simply creating what the Python API calls a "session" - a connection to gnucash will allows for the input and retrieval of GnuCash data. The Python API Session object seems to wraps the c functions: qof_session_new, qof_session_begin, and qof_session_load. The swig interface I found does not seem to export these out as Guile procedures.
> 
> Any advice on using the Guile API in general or how to create a session using Guile in particular?

Alex,

Actually, more of GnuCash is exposed to Guile than to Python because Python can’t see the parts of GnuCash that are written in Scheme. Everything in the C API that’s exposed to one is exposed to the other; the differences in the SWIG interface files are just customizations needed to make a function work in the language in question. If there’s no customization it means that SWIG can figure out the right thing to do from the C header, and unless a function whose header is included in a SWIG file is specifically %excluded in the SWIG file it’s exported.

What’s more, GnuCash links libguile and starts the Scheme interpreter very early, so you can actually customize the application with Scheme. This is how one adds custom reports.

That aside, qof_session_new *is* mentioned explicitly in engine.i outside of the language-specific sections, at line 163. You can see it in action in src/engine/test/test-create-account.scm and test-dcm-query-import.scm

Regards,
John Ralls


More information about the gnucash-user mailing list