Am Samstag, 5. November 2011 schrieb John Ralls: > >> Why do we need this? QofBook already has a read-only attribute which > >> prevents even editing instances, so there shouldn't ever be anything to > >> save in a read-only session. > > > > My goal is to implement a "read-only" operation mode of gnucash, so that > > our infamous "The database is locked" dialog offers the choice "Open > > read-only" (instead of or additionally to "Open anyway"). > > > > For this, the read-only attribute needs to be stored in the same place as > > the database URL. That one is stored in QofSession, so the fact it's a > > read-only URL needs to be stored in QofSession, too. > > Christian, > > That's an excellent idea, but I think you need to re-analyze the code a > bit. In particular, this section of src/gnome-utils/gnc-file.c, in > gnc_post_file_open(): > > 870 if (uh_oh && (io_err == ERR_SQL_DB_TOO_OLD || > 871 io_err == ERR_SQL_DB_TOO_NEW)) > 872 { > 873 qof_book_mark_readonly(qof_session_get_book(new_session)); > 874 uh_oh = FALSE; > 875 } > > This is the *same function* that displays that dialog box. All that you > need is a button on the dialog box to set a local variable in that > function and add the variable as a condition to the above conditional and > you're done. > > While QofSession has facilities for multiple books, it really only made > sense to do that in the old "gemini" book-closing scheme, which was never > fully implemented (and a large part of which I removed over the summer) -- > and in any case it allows only one open/active book > (qof_session_get_book() doesn't return a list). What use-case do you have > in mind that would need multiple books in a session, especially multiple > *active* books?
Ok, I'll re-consider the need for an additional flag in QofSession. As you might already notice in r21526, I checked whether a second book is ever added to a QofSession, which is not the case and due to this I've removed the function to do so. Subsequently, the 1:N relation of session and book can and should be simplified to a 1:1 relation and in that case the read-only flag is most likely sufficient in QofBook. I'll revert r21517 when I implement more parts of the feature I need. > qof_session_safe_save() is for upgrading the sql database in place. I can > understand that if the file/session/db is to be read-only that that should > be blocked, but that can be accomplished inside of gnc_post_file_open(), > the only place that safe_save() is called. Ok, I'll check that. Thanks. Best Regards, Christian _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel