@fenuks - in Calibre 0.7.55 this setting was changed from being a tweak to being a setting on that Preferences->Behavior screen. It appears I should now be reading the setting from prefs.get('bools_are_tristate') instead. The Goodreads Sync plugin (which I copied the code from) has the same problem so I need to update both.
BTW I think you were a bit harsh in your replies to dwanthny, who made a perfectly sensible suggestion in his attempt to help. More often than not he has the right answers having supported thousands of calibre users for many years on these forums. Unless it is stated in the post we have no idea what things the person has already tried or what their technical level is. In my opinion there is never a justification for any negative attitude if the suggestion isn't the right solution. A simple "thanks for the suggestion but I have tried that without any luck" would suffice, we are all just volunteers in our spare time trying to keep calibre users happy to spread the love