View Single Post
Old 03-12-2011, 05:16 AM   #12
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,732
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Hi Charles,

That was a simplified example to replicate the error. Perhaps I should explain exactly what I am trying to do.

This is for my manage series plugin, and a tester suggested they wanted the ability to manage custom series columns as well as the built in series one. So in my dialog I have a dropdown allowing the user to select which column to manipulate which changes the set of values displayed and updated.

In this dialog the user can also add empty books to fill in gaps in a series. That means they may or may not decide to populate the custom series column, depending on which column they had chosen to manipulate in my dialog. After all, not all series columns will have a value.

If I was to use this approach instead of set_all_metadata:
Code:
        meta = db.metadata_for_field(key)
        mi.set_user_metadata(key, meta)
        mi.set(key, val=whatever_it_is, extra=whatever_it_is)
For just the custom series column(s) the user manipulates in the dialog, is that the appropriate solution for those empty book rows? As I said above my concern is to make sure that the Metadata object is valid to be saved with set_metadata, and if I only "partially fill it" by setting just one or two series columns on it then does that have no detrimental effect on any other non-relevant custom columns that I will not be touching?

Your point about not trusting the source of the custom column is a very interesting one, I appreciate the warning. However what is the appropriate approach to overwrite the column in that instance, because the code you showed me just ignores it. Certainly in my case now that would be undesirable - the user would be left with a book that they could not set a value for in that column because in it's original source in some other database the column had a different datatype?
kiwidude is offline   Reply With Quote