Re: python binding: getting invoice entry data

2011-01-19 Thread Brian St. Pierre
I opened a bug and attached a patch that seems to fix the problem:

https://bugzilla.gnome.org/show_bug.cgi?id=639980

There is a similar piece of code in
src/optional/python-bindings/glib.i, but changing this did not seem to
have an effect.

-Brian
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: python binding: getting invoice entry data

2011-01-19 Thread Brian St. Pierre
On Wed, Jan 19, 2011 at 7:14 AM, Christoph Holtermann
 wrote:
> 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.
>>
>> 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).

Thanks. I was wondering if it was a SWIG problem. I will take a stab
at fixing the headers.

-Brian
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


python binding: getting invoice entry data

2011-01-18 Thread 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_module_init_backend_dbi()] No
DBD drivers found
Traceback (most recent call last):
  File "invoice_read.py", line 16, in 
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?

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