GNOME Bugzilla – Bug 528184
Write OpenSearch module
Last modified: 2009-01-30 20:16:43 UTC
The module should be able to search any OpenSearch compliant site given the OpenSearch description document, parse the results and present them. The googlecodesearch module already parses results in Atom format. The OpenSearch specification is available at http://www.opensearch.org/Specifications/OpenSearch/1.1/Draft_3 A guide on how to write Deskbar-Applet modules is available at http://www.k-d-w.org/deskbar/new-style_modules.html
I would like to solve this one, but I could use some mentoring as I am new to OpenSource development (not new to programming of course :) ). This bug was tagged with gnome-love, so are you willing to mentor me for this 'bug'?
That's great. The task is yours ;) I'll try to answer all your questions. You can contact me via e-mail or #deskbar on GimpNet, too. If you have any code, please attach it here and I'll review it.
How's the status of the module?
Development of the module is going okay. Right now I have got the following working: - Parsing and presenting search results (both Atom and RSS) - Adding, editing and removing search sites using dialogs To do: - Parsing description documents - Error handling - Perhaps tweaking the looks I might be able to submit a beta version for review at the end of this week.
That's awesome! I'd love to see some code.
Created attachment 112437 [details] beta
Please find the code for the module attached. It is not the final product, but it has all the basic functionality. Have a look at the code and toy around with the module. I'd be glad to hear your feedback.
Wow, thanks a lot for all your work. I had a look at your code and played with it a little bit. Here are some issues I came across (in no particular order). Maybe you came across some of them already yourself. 1) When pressing "More..." in preferences when the module is _not_ enabled:
+ Trace 200050
file = open(SETTINGS_FILE, 'rb')
10) Currently, you're only replacing {searchTerms} in the template Url, but there are more placeholders. You should choose reasonable default values if applicable. This seems like a lot, but it's a rather complex issue where many things can go wrong. Nevertheless, it's already a very good start. If you need some assistance in coding, let me know.
Thank you for your (quick) feedback Sebastian. This is very useful. I will handle these ten issues one by one in the coming days. When the next version is ready for testing I will post it here. Any tips for logging, besides writing to a file? Perhaps something more 'direct'?
That's awesome! I'm using the logging module[1]. E.g. the beagle-live module makes use of it. [1]: http://docs.python.org/lib/module-logging.html
Created attachment 112676 [details] beta (2) Applied changes to solve the issues in Comment #8. Please review.
Thanks! This version is almost perfect. There are some minor issues: 1) When selecting an item in preferences and deselecting it the icons aren't marked in sensitive. Use treeview.get_selection().connect("changed", ...) 2) When an RSS item contains a description field display it with Match.set_snippet 3) You should use MessageDialog with gtk.MESSAGE_ERROR instead of WARNING. 4) Don't hard code .gnome2/deskbar-applet use deskbar.USER_DESKBAR_DIR instead 5) Don't use custom logger, but the logging module. 6) In preferences put url entry first and put the pointer by default in there 7) The icon for OpenSearchMatch is currently gtk-file and category actions. This doesn't fit at all. You should use the websearch category with it's default icon. Some description files seem to provide a URL to icon. What would really rock is if the module would download the icon use it instead of the default one. Beside that it's excellent work!
Created attachment 114217 [details] beta (3) I solved the issues as far as I could, but I have difficulties in three remaining cases: 1. Match.set_snippet() gives me trouble (it looks so simple!). If I uncomment the code in line 64 the program fails. Please advise. 2. Showing the image from the description document: It was not easy to get this working, and when it worked it did not look great (the Image does not necessarily look like an icon, it is often a larger image). I'm not sure if this is a desired feature after all. If you want to check it out, uncomment the code in lines 98-108 3. Somehow I can't get the python logging module to work. It just doesn't log, whatever I try. Could you show me how to set it up, please?
1. Do you have deskbar-applet from svn trunk? 2. Your right, I didn't consider that. We should just ignore the image then. 3. Put this at the top of the file: import logging LOGGER = logging.getLogger (__name__) then you can do LOGGER.info(), LOGGER.warning(), LOGGER.debug() and so on. I discovered a problem when the template url contains the count parameter (e.g. http://wikitravel.org/en/Special:OpenSearch/description). Currently, you set the value for all additional parameters to 0. That's not a good idea. In this particular case no results are returned. You should check which optional parameters exist and choose sane default values for each of them (e.g. 20 for count). All other issues I mentioned before are fixed in this version. Thanks a lot for your work. If you have an updated version please upload it here.
Are you still working on this? I would love to include it in 2.24.
I fixed the remaining bugs and did some cleanup. It's now part of svn trunk.