[PATCH] [REVIEW] python bindings and lost business data

Mike Evans mikee at saxicola.idps.co.uk
Sun Jun 13 05:13:06 EDT 2010


On Thursday June 10 2010 00:53:44 Mark Jenkins wrote:
> > Back to bug killing.
> 
> I came up with the attached patch to stop business objects from being lost.
> 
> The modules "gnucash/business-core-xml" and "gnucash/business-core-sql"
> are now loaded.
> 
> I've tested this with
> 
> >>> from gnucash import Session
> >>> s = Session('sqlite3:///full_path_to_file')
> >>> s.save()
> >>> s.end()
> 
> Will test more tomorrow, but I thought it was a good time for feedback
> right now.
> 
> I'd appreciate it if there could be some review as to this being the
> right approach or not. You don't actually have to know anything about
> python or swig to help with this crucial part of the python bindings.
> The init section in src/optional/python-bindings/gnucash_core.i is
> simply C code that is called before any other GnuCash functions (like
> qof_session_new) are called.
> 
> This, and the linking decisions in Makefile.am are the most critical
> elements of the python bindings. Everything else is high level fluff to
> create a object oriented API instead of the C style API. The content
> really should be no different than what a C programmer trying to use the
> GnuCash API in a fresh application would have to write prior to running
> through a sequence of qof_session_new, qof_session_begin,
> qof_session_load, qof_session_save, and qof_session_end .
> 
> With this patch, this init section in gnucash_core.i becomes:
> g_type_init();
> scm_init_guile();
> gnc_module_load("gnucash/engine", 0);
> gnc_module_load("gnucash/business-core", 0);
> gnc_module_load("gnucash/business-core-xml", 0);
> gnc_module_load("gnucash/business-core-sql", 0);
> 
> It strikes me as over kill that scheme is needed for this, but its my
> understanding that the gnc_module stuff depends on that.
> 
> I took a first stab at looking for another approach. I looked into what
> the cutecash folks had done and came up with this:
> """
> qof_log_init();
> qof_init();
> gnc_module_system_init();
> char * no_args[1] = { NULL };
> gnc_engine_init_static(0, no_args);
> 
> gnc_module_init_backend_xml();
> gnc_module_init_backend_dbi();
> gnc_module_init_business_core_init();
> gnc_module_init_business_core_xml_init();
> 
> void gnc_address_sql_initialize( void );
> void gnc_billterm_sql_initialize( void );
> void gnc_customer_sql_initialize( void );
> void gnc_employee_sql_initialize( void );
> void gnc_entry_sql_initialize( void );
> void gnc_invoice_sql_initialize( void );
> void gnc_job_sql_initialize( void );
> void gnc_order_sql_initialize( void );
> void gnc_owner_sql_initialize( void );
> void gnc_taxtable_sql_initialize( void );
> void gnc_vendor_sql_initialize( void );
> 
> gnc_address_sql_initialize();
> gnc_billterm_sql_initialize();
> gnc_customer_sql_initialize();
> gnc_employee_sql_initialize();
> gnc_entry_sql_initialize();
> gnc_invoice_sql_initialize();
> gnc_job_sql_initialize();
> gnc_order_sql_initialize();
> gnc_owner_sql_initialize();
> gnc_taxtable_sql_initialize();
> gnc_vendor_sql_initialize();
> """
> 
> That also seemed to work, but the additional linking I had to throw to
> _gnucash_core_c_la_LIBADD (from
> src/optional/python-bindings/Makefile.am) in against
> ${top_builddir}/src/backend/xml/libgncmod-backend-xml.la
> ${top_builddir}/src/business/business-core/xml/libgncmod-business-backend-x
> ml.la
> 
> ${top_builddir}/src/backend/dbi/libgncmod-backend-dbi.la
> and
> ${top_builddir}/src/business/business-core/sql/libgncmod-business-backend-s
> ql.la
> 
> resulted in a warning that linking against those wasn't portable.
> 
> 
> Any advice?
> 
> 
> Mark
The patch works, I can now insert a sale into the database and not lose 
business data.  Will try making an invoice next.
Thanks Mark




-- 
GPG Key: 1024D/050895C2
Keyserver: http://pgp.mit.edu/          
Search String: 0x050895C2


More information about the gnucash-devel mailing list