View Single Post
Old 07-08-2012, 01:15 PM   #529
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,500
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by JimmXinu View Post
@Jade Aislin - Yes, it's the {#character1:subitems(-1,0)} composite column. Using that, I'm able to duplicate the problem.

A composite of {#characters}, {#genre} still worked, however, so it has to do with the subitems function call.

So this is either a problem of "you're not using it right", or calibre not interpreting the subitems template function in the composite column right away.

If you believe it's the latter, you'll need to take it up with the calibre devs. I can help demonstrate the problem, if needed.
I am going to jump in here after reading something on the generate cover thread. I have no idea what this plugin does, but as I wrote the custom column and template code in calibre, perhaps I can help.

If I understand the last couple of posts correctly, in some cases a composite column appears to have delayed evaluation. I interpret this as saying that at point A the value is wrong, where later it becomes correct.

This behavior can happen if point A is when new books are added but before calibre's data cache is refreshed, and point B is after the cache is refreshed. The cache for a changed book tends to be refreshed when the calibre GUI displays the line for that book. It can also be explicitly refreshed.

Because of this characteristic, if a plugin does the sequence:

1) add a book.
2) add metadata to the book.
3) mi = get_metadata()
4) do something with the mi structure

then the composite columns in the mi will not have the correct values. Why? It gets the values from the data cache, and the data cache is not yet up-to-date. The same thing will be true if 1) and 2) are instead "change metadata".

If the plugin is doing the above or something like it, then between steps 2 and 3 (I think) it should do "db.refresh_ids([list of book ids])", where "db" is the database object that you should already have. The list of IDs should contain all the ids that you will pass to get_metadata.
chaley is offline