Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 10-11-2012, 04:00 AM   #1
Pepin33
Zealot
Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.
 
Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
Getting last added books

Is there a way to get the ids for the last added books after using the gui.iactions['Add Books']?

I know I can get last modified book from iactions using db.last_modified(). But... what about last added book(s)?
Pepin33 is offline   Reply With Quote
Old 10-11-2012, 04:37 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Not directly, but you can simply get all ids before and after the operation. As long as no other jobs are running in the interim that is reliable, or you can directly use the db interface to add books instead of using the iaction.
kovidgoyal is offline   Reply With Quote
Advert
Old 10-11-2012, 05:03 AM   #3
Pepin33
Zealot
Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.
 
Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
Thanks, kovidgoyal. The method of get ids before and after the iaction was already my "second solution".

The use of iaction instead of the db is because this way I don't need to create any user interface window (iaction has it own user interface).
Pepin33 is offline   Reply With Quote
Old 10-11-2012, 06:11 AM   #4
Pepin33
Zealot
Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.
 
Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
I have another problem: I read book ids in library, then I lauch iaction for adding books, after that I read again for ids in library.... and I get same ids list than before!

I know that it's because iaction for adding books uses an Adder object that uses a "worker" to make the job and returns control to main function. So when I read ids for second time, the worker is still working, and I get no new ids.

Any way to solve this?
Pepin33 is offline   Reply With Quote
Old 10-11-2012, 06:13 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use a timer an keep polling till you have the new ids. Or you can be sophisticated and monkey patch the callback function on the iaction object so that your callback is called instead. Just remeber to retore the original function after you are done.
kovidgoyal is offline   Reply With Quote
Advert
Old 10-11-2012, 07:19 AM   #6
Pepin33
Zealot
Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.Pepin33 has a complete set of Star Wars action figures.
 
Posts: 109
Karma: 419
Join Date: Aug 2012
Location: Spain
Device: Kindle Touch
Smile

Quote:
Originally Posted by kovidgoyal View Post
Use a timer an keep polling till you have the new ids.
This is not a good solution, because the user may cancel the iaction, and we never will get new ids.

Quote:
Originally Posted by kovidgoyal View Post
Or you can be sophisticated and monkey patch the callback function on the iaction object so that your callback is called instead. Just remeber to retore the original function after you are done.
I had no idea about what a monkey patch was. But google is my friend, so I search, found... and it works!
I monkey patch the "_files_added" function at the iaction to make its work, and then to call my own function to get the ids. And works OK.

Thank you again for your help, kovidgoyal, you're the king!

Last edited by Pepin33; 10-11-2012 at 01:02 PM.
Pepin33 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Books added by Calibre eLDiaNo Devices 5 10-08-2012 12:32 PM
Title language of added books panovvladislav Calibre 2 03-25-2012 06:50 AM
books do not show on device after being added vague_hit Calibre 3 02-09-2012 08:30 AM
After aborting, are books still added to library? vitalichka Calibre 4 01-15-2011 11:15 AM
Added personal books to the EB1150 =X= Fictionwise eBookwise 8 08-15-2008 10:51 PM


All times are GMT -4. The time now is 05:59 PM.


MobileRead.com is a privately owned, operated and funded community.