r16543 - gnucash/branches/gda-dev/src - Make GDA backend (sqlite) the default if file: or no access method is

Phil Longstaff plongstaff at rogers.com
Mon Sep 24 22:58:12 EDT 2007


   Derek Atkins wrote:

Phil Longstaff [1]<plongstaff at rogers.com> writes:



The UI doesn't support xml: (or any access method) but it can be entered from
the command line i.e. gnucash xml:...


Yeah, we should probably fix this..  Or add other "File -> Open"
methods to let the user choose the specific version.



   I have a modified version of src/gnome-utils/gnc-file.c which allows you to
   select "xml:"  The gtk_file_chooser returns either the selected uri (with
   [2]file:// in front) or the selected file (with full path).  In both of
   these  cases,  if  you  type  [3]"xml:foo"  as  a  file  name, you get
   "/path/[4]xml:foo".  My version will remove the path (which can be obtained
   from  gtk_file_chooser)  and separates out "xml:" and puts it all back
   together as [5]"xml:/path/foo" which works.  This allows you to navigate to
   the  correct directory and type [6]"xml:filename".  If you try to type
   [7]"xml:/path/file", you get an error dialog from gtk_file_chooser because
   it   looks   for   a   directory  named  "xml:"  and  can't  find  it.
   [8]"xml:subdir/file" also doesn't work because gtk_file_chooser looks for a
   directory named [9]"xml:subdir".
   In  any  case, our db/file chooser could get a bit hairy.  If you want
   postgres/mysql/other     db,     you    would    need    to    specify
   host/username/password/dbname.  GDA has a way of creating pre-specified db
   connections, so we would need to allow the user to select one of these.  For
   xml or sqlite, it's a simple file.

It does file-type auto-detection but there is also the wrinkle that ".db" is
added for sqlite files.  So, if you want to open "foo", first the gda/sqlite
backend look to see if "foo.db" exists and is an sqlite file. If so, it is
used.  If, not, it then checks to see if "foo" exists.  If so, the gda/sqlite
backend assumes that it is a different type of file and lets the xml backend
have a go at it.  If "foo" doesn't exist, the gda/sqlite backend will create
"foo.db".


Is ".db" actually required?  Is there some way to test the file and
then choose which backend to use?



   ".db"  is  added by the sqlite provider for libgda and can't be gotten
   around.  I use the fact that qof can have multiple backends which match the
   same access provider (in this case, "file:") and will try them in order.
   The GDA backend gets first shot and then XML.  It has to be this order to
   make sqlite the default for "file:" files.
BTW, what is the qsf backend?  It seems to exist independent of the XML backend
 but also processes XML files.

   Phil

References

   1. mailto:plongstaff at rogers.com
   2. file://localhost/
   3. xml:foo
   4. xml:foo
   5. xml:/path/foo
   6. xml:filename
   7. xml:/path/file
   8. xml:subdir/file
   9. xml:subdir


More information about the gnucash-devel mailing list