Quote:
Originally Posted by Wiggo
Is there any difference in terms of e.g. perfomance between the 3?
Which one would you choose?
|
The Python templates are *much* faster than the GPM templates. I would pick one of them. However, that might affect how you can maintain them.
Quote:
Edit: ahh, with python the view is always cleared.
|
The templates I provided don't take into consideration the fix I made (in source but not released). They both will clear a virtual library. The search version shows only the requested book (the result of the search).
Given my fix, I would use a modified version of the first template that generates show-book links. It is functionally equivalent to the original GPM template, including not clearing searches, but much faster.
Code:
python:
def evaluate(book, context):
cache = context.db.new_api
ids = book.get('#mytextmult', [])
answer = []
for id_ in ids:
if cache.has_id(int(id_)):
answer.append(f'<a href="calibre://show-book/_/{id_}">{id_}</a>')
else:
answer.append(f"Book id {id_} doesn't exist")
return ', '.join(answer)