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 06-13-2011, 08:21 AM   #1
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,224
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Search restrictions and search_getting_ids

I had to jump through quite a few hoops with the Find Duplicates plugin and facing some similar (but not identical) issues with Quality Check.

The issue is search restrictions and a clean way of passing a valid restriction to search_getting_ids().

Originally in QualityCheck I applied an actual search to the library view (like "formats:epub") before grabbing all the ids in the view. Thus I was able to avoid thinking about restrictions, as they were applied transparently in the background to the view, and whether the restriction was or was not in place was irrelevant to my plugin.

However this approach does not work if the user has highlighting turned on, as the set of ids I was getting back from the model of course cover all rows with just the epub ones highlighted.

So instead I changed to use "db.search_getting_ids()" which is a nicer approach anyway (since I don't have to change the view).

The second parameter is the search restriction to be applied. This is where things come unstuck, which is likely entirely due to my ignorance. I need to get a search restriction value to pass to the search_getting_ids() call every time I want to use it, in order to respect any search restriction that might be applied.

Where do I get a value from that represents a search restriction that search_getting_ids will understand? I cannot use gui.search.search_restriction as that only works for "current" type search restrictions, not for saved searches.

Hopefully there is a simple value somewhere I can use... ?
kiwidude is offline   Reply With Quote
Old 06-13-2011, 08:32 AM   #2
chaley
"chaley", not "charley"
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: 5,193
Karma: 821512
Join Date: Jan 2010
Location: France
Device: Many android devices
The search restriction must be a valid search as would go in the search box. It is up to you to generate such a thing.

If what you have is a search restriction name (a saved search name), then the restriction search is generated using something like
Code:
'search:"%s"'%(saved_search_name)
Or are you doing something else?
chaley is offline   Reply With Quote
Old 06-13-2011, 08:40 AM   #3
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,224
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Perhaps I didn't explain very well. All I want to do is get a value to pass to search_getting_ids for it's second parameter of "restriction", which represents whatever the current restriction is that the user has applied in Calibre. As I said above I cannot use self.gui.search.search_restiction, because I will get a value of a saved search name in some cases, and actual text representing the restriction in others, depending on whether the user last applied a current search or a named restriction.

To get around this I can go down the FindDuplicates route of looking at the text in the combo, seeing if it starts with a * or not and then manipulating that into a value search_getting_ids can cope with. However that is something I would need to repeatedly do everywhere I call search_getting_ids(). I wondered if there was somewhere else that would give me the "underlying" value without requiring me to manipulate it.
kiwidude is offline   Reply With Quote
Old 06-13-2011, 08:46 AM   #4
chaley
"chaley", not "charley"
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: 5,193
Karma: 821512
Join Date: Jan 2010
Location: France
Device: Many android devices
You can get the current search restriction (the one in effect because the user did something) via db.data.search_restriction.
chaley is offline   Reply With Quote
Old 06-13-2011, 08:56 AM   #5
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,224
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Perfect, thanks. Hoped it was around somewhere...
kiwidude 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
Geo Restrictions emmad Amazon Kindle 30 09-20-2010 07:22 AM
More App Restrictions kennyc Apple Devices 12 06-02-2010 02:29 PM
No Geo-restrictions seagull Deals, Freebies, and Resources (No Self-Promotion) 3 12-14-2009 01:07 AM
Regional restrictions now in the UK tech_au News 166 10-26-2009 02:52 PM
Google Book Search to search full-text books online Bob Russell Deals, Freebies, and Resources (No Self-Promotion) 1 08-19-2006 12:13 PM


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


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