access_method and new, empty, sessions.

Derek Atkins warlord at MIT.EDU
Wed Feb 16 16:30:48 EST 2005


Neil Williams <linux at codehelp.co.uk> writes:

> In the g2 branch, I adapted qofsession.c to handle QSF using the QOF 
> load_backend_library routine in qof_session_load_backend().
>
> Loading an existing file is handled fine, because the routines inspect the 
> file contents and report back on what kind of content is found. QSF needs a 
> few more tweaks to load files properly but g2 always tells the difference 
> between gnucash-xml-v2, v1 or binary vs QSF. That's good - the access_method 
> is not a problem here.
> :-)
>
> (The tweaked code will be in CVS - g2 - soon, it's working locally).

Excellent.

> I'm now trying to see how it can work when qof_session_new() and 
> qof_session_begin() are called where no content exists, i.e. new, empty, 
> sessions.

You mean what to do when we use File -> Save As?  I think in general
from the user standpoint it's fairly "obvious" what they want.  The
user is never going to "File -> Save As" QSF, it's always going to
save as the "primary" file:// method.

> Is the access_method more of an identifier than a reflection of a protocol?

If I'm understanding what you're asking, yes.  We're not using IANA
protocol definitions in the discriminator.  The "protocol" field is
just a tool to allow the user to differentiate between different
access methods.  Generally they have two choices now, file:// or
postgres://

> Can we invent new access_method strings that have no basis in real protocols? 

Yes.  We had rpc:// which isn't a "real" protocol (at least as far as
IANA is concerned).

> (Dialogs and other code can determine which is to be used, there's no reason 
> for users to worry or know about the access_method - is there?)

In general this is true.  I suspect there will be multiple dialogs (or
perhaps a "file format" option in a combined dialog) to let the user
choose what format they want to use when saving/exporting data.

> How should I proceed to discriminate two backends that use the same 
> access_method when no content exists yet?

Do you necessarily need to choose up front?  Where are the cases when
this is an issue?  AFAICT it's only an "issue" during File -> New File
or when you run (effectively) gnucash --nofile.  At that point the
user clicking on "save" is effectively calling Save As.

> Should I use and support:
> session = qof_session_new();
> qof_session_begin(session, "qsf:/somefile.xml", TRUE, FALSE);
>
> using an arbitrary qsf:/ access_method? 

If you want.  Do you need to do so?

> (Loading an existing file that contains QSF data using file:// will still load 
> it as a QSF file.)
>
> Is there an alternative method?

I don't know, I haven't looked at that code extensively.  But keep in
mind that it's going to get much more complex once we add SQLite to
the mix.

-derek

-- 
       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