Using GList types as a parameter via the Python bindings

Tom Lofts dev at loftx.co.uk
Sat Jun 1 04:24:33 EDT 2013


Hi there,

As part of some of work I've been doing relating the the Python bindings 
I've come across a number of functions which take a Glist data type.

I was originally attempting to work with the 
qof_query_add_guid_list_match function, but after encountering 
difficulties I've been testing with xaccSplitListGetUniqueTransactions 
which takes a Glist of splits and returns a Glist (presumably of 
transactions)

So the following code:

print gnucash.gnucash_core_c.xaccSplitListGetUniqueTransactions(swig_splits)

But receive the error:

Traceback (most recent call last):
   File "./gnucash_rest.py", line 420, in <module>
     print 
gnucash.gnucash_core_c.xaccSplitListGetUniqueTransactions(swig_splits)
   File 
"/usr/local/lib/python2.7/dist-packages/gnucash/gnucash_core_c.py", line 
245, in xaccSplitListGetUniqueTransactions
     return _gnucash_core_c.xaccSplitListGetUniqueTransactions(*args)
TypeError: in method 'xaccSplitListGetUniqueTransactions', argument 1 of 
type 'GList const *'

I was assuming I'd be able to pass a Python list in as the parameter to 
this function and it would be correctly converted by SWIG into a GList 
as the reverse seems to happen on functions which return a GList such as 
qof_query_run.

Does anyone have any advice on what I may need to do to avoid this error 
or if some sort of change needs to be made to the SWIG interface?

Thanks,

Tom


More information about the gnucash-devel mailing list