View Single Post
Old 08-24-2022, 06:05 PM   #13
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,641
Karma: 7908443
Join Date: Sep 2020
Device: none
Quote:
Originally Posted by chaley View Post
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?
Attached Files
File Type: zip code placement question.zip (2.4 KB, 85 views)
Comfy.n is offline   Reply With Quote