Hello ! Am 19.01.2011 05:16, schrieb Brian St. Pierre: > I'm trying to use the python bindings to fetch entry (line-item) data > from an invoice. > > See http://pastebin.com/fy06CPup for the test GnuCash XML file I'm using. > > I expect the script below to print the three line items from the > invoice in that file, but instead it dies with: > > % gnucash-env python invoice_read.py test2.gnucash > * 15:07:39 WARN <gnc.backend.dbi> [gnc_module_init_backend_dbi()] No > DBD drivers found > Traceback (most recent call last): > File "invoice_read.py", line 16, in <module> > print entry.GetDescription() > File "/usr/lib/python2.6/dist-packages/gnucash/function_class.py", > line 92, in method_function > *process_list_convert_to_instance(meth_func_args) ) > File "/usr/lib/python2.6/dist-packages/gnucash/gnucash_core_c.py", > line 3825, in gncEntryGetDescription > return _gnucash_core_c.gncEntryGetDescription(*args) > TypeError: in method 'gncEntryGetDescription', argument 1 of type > 'GncEntry const *' > > Other methods on the Entry objects yield similar results. (A similar > approach to the code below with Invoice and Customer objects works > ok.) > > Running on Ubuntu Lucid. Tested with 2.4.0-1~getdeb1~lucid from > getdeb.net and from svn with the same results. > > Can someone point out what I'm doing wrong? You just encountered an open end in the python-bindings. It's a problem of the SWIG-headers. It is often encountered in uncharted territory ;-) As far as i know the only way to get around that is to change the SWIG-headers. That has to be done by someone wiser than me. There is no way to force python to accept other types, is there ? (I have been looking for that for quite a while).
In the python level sometimes there are possibilities to work around. But i can't find GncEntry anywhere and the only functions that seems to return a pointer to an GncEntry gncEntryLookup which has to be fed with a book and a guid. But i don't see how to get the guid of an entry. regards, Christoph Holtermann > Thanks. > > -- > Brian St. Pierre > > > > #!/usr/bin/env python > import os > import sys > > from gnucash import Session > from gnucash.gnucash_business import Entry > > uri = "xml://{0}".format(os.path.abspath(sys.argv[1])) > ses = Session(uri, is_new=False) > try: > book = ses.get_book() > invoice = book.InvoiceLookupByID('0001') > assert(len(invoice.GetEntries()) == 3) > for e in invoice.GetEntries(): > entry = Entry(instance=e) > print entry.GetDescription() > finally: > ses.end() > _______________________________________________ > gnucash-devel mailing list > gnucash-devel@gnucash.org > https://lists.gnucash.org/mailman/listinfo/gnucash-devel _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel