Quote:
Originally Posted by capink
@chaley: I have implemented the changes, and they are working OK. The modifications you made to templates have simplified things for me, and the global variables opened up some new possibilities as well.
|
Sorry, but I am not sure what you want to do. Guessing ...
- There isn't an easy way to reuse the template search mechanism. It is built into search. That said, you can of course pass template searches into calibre.db.search and get a list of book ids that match. However, there isn't any way to pass the globals dict into search because it uses its own copy of the formatter.
- If you want to use a template to control a chain then you can define its behavior. You would invoke a template with the appropriate globals dict and run the chain if it returned an acceptable value. If possible I would avoid using datatypes, instead asking for a string value. This wasn't really practical for searches because the search language already had typed expressions. If you want to implement typed expressions then you will need to do it yourself.
The big question for controlling a chain is whether the selected books have a role. This avoids needing the mechanism to specify the type of the response.
- It might be that you want to execute a template without having a book. You should be able to do this by passing Metadata() as mi along with the globals dict. The globals dict would have been filled in with the values related to the chain.
- It might be that you want to be able to pass a globals dict to the existing template tester. After a quick glance at the code I think I could do that.
What are you looking for?