View Single Post
Old 10-12-2022, 04:33 PM   #52
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,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by capink View Post
The whole PTM thing is going to open up a lot of possibilities. e.g. combining PTM with template search, you can use data from one library (authors library), to search for books in another. Which brings up the question, now that this is not implemented as a method, how can I persist the data, say for the duration of template search.

Edit: The context object or the globals dict can be used for this.
The cached template can also be used for this if the lifetime works.

The cached compiled template's lifetime is
  • for template searches, the duration of the search.
  • For composite columns, until some metadata changes.
  • For the template tester, one call
  • For most everything else, one call
You can use these by defining attributes in the template at the outermost level.

You can also define persistent attributes in various ways then give a template access to the attributes in some way or another.

As for "other possibilities", yes. A PTM template can do a lot of things, for example interact with the GUI. It can search, add and remove category items, and modify metadata; then tell the GUI to refresh. I am not convinced this is a good idea for lots of reasons, but no matter what I think the templates can do it because they have access to the calibre API,
chaley is offline   Reply With Quote