QSF Import of gncCustomer and gncAddress Issues (and partial success)

Derek Atkins warlord at MIT.EDU
Mon May 29 10:39:47 EDT 2006


Hi.

We've disabled QSF Import/Export for now because that subsystem is
still very unstable...  Too unstable for the upcoming stable release.
But yes, you can send patches here.  "svn diff" is good enough.  Your
other options is to file a bug report and attach your patch to the
bug report.  That's less likely to get lost than an email message.

If you plan to send it soon, I'd recommend a bug report, because I
dont think we have plans to patch QSF prior to the 2.0 release.

-derek

Quoting Georgi Mirchev <manager at mirchevideas.com>:

> For the last days I have been trying hard to make gnucash import QSF 
> data, in native format (i.e. without mapping, just the raw QOF 
> objects). The data I wanted to go first with is a single customer 
> record. The customer has an address record.
> Let me state that I had A LOT of problems. Here are a few comments of 
> my way of handling things, bug reports, the success report, and 
> improvement suggestions.
>
> Please note that this is the first time I'm reading all this QOF/QSF 
> code, so I might be wrong here or there.
>
> First I took vcard-gnccustomer.pl, and extracted only the XML 
> structure out of the source, so that I can write my own XML file with 
> one customer, with their address. I checked that it is well formed, 
> and read the DTD, so that my XML file is ok with it. Onwards. I went 
> to import the file. And I got error that the file cannot be imported, 
> no error code, no error description. Very informational :-) An hour 
> later I found that the QSF file backend actually returns error codes, 
> in the form of random and non-unique negative numbers. So I changed 
> them to other random, but at least unique negative error codes, and 
> modified the error message to include them. Voila, I get an error 
> code :-)
>
> My happiness didn't last long, since the code didn't help me at all. 
> Suffice to say that a few hours later I found out that the QSF 
> backend returns well specified error codes, and keeps a stack of 
> them. Why, the heck (I wanted to put something else here, but I'm 
> worried the message will get censored), these codes don't get passed 
> to the wizard and the wizard doesn't print informative error message. 
> In my case the problem turned out that I have empty GUID for the 
> book. I took this code from vcard-gnccustomer.pl, so as a side note, 
> this perl file doesn't generate valid QSF files.
>
> SUGGESTION: Make QSF import wizard print informative error messages 
> based on error codes returned from the QSF backed.
>
> So we are in the wizard now. Import successful. Checking what we have 
> imported - customer is there, address is empty. Halfway I thought. I 
> couldn't been more wrong. It took 5 times more time to figure how to 
> connect the customer and the address.
>
> First it turned out that the XML printed by vcard-gnccustomer.pl 
> doesn't contain the correct references. Fixed that, but still the 
> file didn't import right. It turned out that the reference setting 
> code in QSF file backend doesn't set the references right. More 
> debugging showed that that code actually never worked right, because 
> after some fixes, it turned out that there is a piece of code that 
> has never been actually executed before, which always segfaults on 
> execution. The bug was simple and got a simple fix. The other is that 
> the function actually increase the list pointer to the end of list on 
> the first execution, so it has a logic error.
>
> BUG: ent_ref_cb() has several bugs
>
> The bigger issue is that the reference handling code has a number of 
> logic error. I managed to get it to work by hard-coding my GUIDs. The 
> problem is that the references has to be read before all other 
> elements, instead, as currently, with them. This pre-pass is required 
> because when reading the GUID elements the references have be found. 
> I'm thinking of writing a patch.
>
> BUG: logic issue with references in QSF backend
>
> Additionally the create_reference() function in QOF doesn't work 
> right. The problem is that it always returns newly generated GUID, 
> instead of taking the GUID from the objects given. What's worse is 
> that both GUID pointers in the reference point to the the same memory 
> space, so updating one of the GUIDs, changes the other. Yummy :-)
>
> BUG: create_reference() doesn't handle GUIDs right
>
> I'll open a different thread about the debug logging issues.
>
> So after some fixing, I managed to import successfully this QSF file:
> <?xml version="1.0" encoding="utf-8"?>
> <qof-qsf xmlns="http://qof.sourceforge.net/">
>    <book count="1">
>        <book-guid>1288f53dc05562a02a94c58458255d55</book-guid>
>        <object type="gncAddress" count="1">
>                <string type="name">Address Name</string>
>                <string type="phone">555 666</string>
>                <string type="email">blah at yahoo.com</string>
>                <string type="street">Some Street</string>
>                <string type="city">Sofia</string>
>                <string type="locality">My Locality</string>
>                <guid type="guid">1144f53dc05562a02a94c58458255d55</guid>
>                <choice type="owner" 
> name="gncCustomer">1244f53dc05562a02a94c58458255d55</choice>
>        </object>
>        <object type="gncCustomer" count="2">
>                <string type="id">123</string>
>                <string type="name">Customer Name</string>
>                <guid type="guid">1244f53dc05562a02a94c58458255d55</guid>
>                <guid type="addr">1144f53dc05562a02a94c58458255d55</guid>
>                <boolean type="active">true</boolean>
>        </object>
>    </book>
> </qof-qsf>
>
> As a last few words, what to do with the patches. Where do I send 
> them for eventual incorporation into the SVN. Also will "svn diff" 
> result be with the right format for the patches? It seems normal 
> unified diff format.
>
> Regards,
> Georgi
>
>
>



-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available



More information about the gnucash-devel mailing list