Quote:
Originally Posted by chaley
FWIW: the refresh_ids should be after the loop, not in the loop. As it is the code is refreshing all books for every book, which could create a performance problem. I suggest
Code:
for book_id in book_ids:
now = datetime.datetime.now()
viewdate = format_date(now, dateformat, assume_utc=False, as_utc=False)
db.set_custom(book_id, viewdate, label=label, commit=True)
if book_ids:
self.gui.library_view.model().refresh_ids(book_ids)
|
Hi Chaley, I used your suggestion, but it gave me an error when installing the plugin, as following:
Code:
ERROR: Unhandled exception: <b>NameError</b>:name 'book_ids' is not defined
[...]
Traceback (most recent call last):
File "calibre\gui2\preferences\plugins.py", line 325, in add_plugin
File "calibre\customize\ui.py", line 479, in add_plugin
File "calibre\customize\ui.py", line 64, in load_plugin
File "calibre\customize\zipplugin.py", line 307, in load
File "polyglot\builtins.py", line 123, in reload
File "importlib\__init__.py", line 169, in reload
File "<frozen importlib._bootstrap>", line 619, in _exec
File "calibre\customize\zipplugin.py", line 208, in exec_module
File "calibre_plugins.auto_datestamp_and_view.__init__", line 23, in <module>
File "calibre_plugins.auto_datestamp_and_view.__init__", line 46, in AutoDatestampAndView
NameError: name 'book_ids' is not defined
I have attached a zip archive containing the code alternatives, perhaps all it needs is some syntax correction?