View Single Post
Old 03-24-2021, 03:40 PM   #424
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,203
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
Running over non selected books is something I always pondered, not just for Single Field Edit, but for all builtin actions with the exception of calibre actions, which have to be always selection based, since the actions are not under the plugin control.

The way I imagined it was a template based solution, where the template returns list of ids. For example, to run over all ids the template below can be used:

Code:
program:
from_search('id', '')
The book_vars ids will need a new template function, since book_vars always act on one selected row (the row containing the current index). Or maybe modify both book_vars and set_book_vars and make them accept id values.

The stumbling block was whether to implement this for each action separately, or can there be a better way to implement a general mechanism used by all actions. Any suggestions would be welcome. This might take some time until I reach a solution I am comfortable with.

Until then we can experiment with custom actions. To that end, I will introduce a change in the next version which will add a new action method — maybe call it loop_ids() — which can be overridden by subclasses to return the ids that will be acted on by the action.

Edit: One concern with this approach will be how handle invalid template output as they will be difficult to validate ahead of time.

Last edited by capink; 03-24-2021 at 03:43 PM.
capink is offline   Reply With Quote