Hi Will, For the first question, I think importing the other plugin's preferences is not the right way to go. What you want is access to the "go_page_today" action. Let the journal plugin figure out how to do that. This way you are much more robust to changes in how the journal plugin works internally.
Probably should have a formal interface to access actions defined by another plugin, but this will work: go_page_today_action = window.ui.actiongroup.get_action('go_page_today') go_page_today_action.activate() page = window.page Thus you only use the "public interface" of the plugin that shows in the user interface and automate that. A secondary benefit is that you don;t even have to know who provides this action. If someone develops an alternative plugin that supports this action, your plugin will still collaborate. If the journal plugin is not loaded, this will fail. Probably it is good to catch that case and show an popup that tells the user to also enable the other plugin. For debugging I myself just throw in a bunch of "print" statements. Of course unittests help to reduce the amount of re-starting you need to do to check functions :) Regards, Jaap On Thu, Mar 30, 2017 at 10:02 PM Will Foran <willforan+ubu...@gmail.com> wrote: > I'm trying extend the Now Button > <https://github.com/Osndok/zim-plugin-nowbutton/blob/master/nowbutton.py> > plugin to use the same path the journal plugin uses by calling > path_from_date. > > I haven't figured out how to respect/load the granularity setting from > preferences.conf. I am trying to explicitly set it using PluginManager or > ConfigManager. Neither with success > > # get cal plug object a la tests/calendar.py > calplugklass = PluginManager.get_plugin_class('calendar') > calplug = calplugklass() > > prefs=calplug.config.get_config_dict('<profile>/preferences.conf') > # ConfigManagerINIConfigFile w/ only with key as "CalendarPlugin", has > default plugin vals (e.g. path=:Journal) > > # OR # > > prefs=zim.config.ConfigManager().get_config_dict('<profile>/preferences.conf') > # ConfigManagerINIConfigFile has all sections of prefs.conf as keys, but > ConfigDict's are all empty > > > > # want to set the cal props like > calplug.preferences = prefs['CalendarPlugin'] > # so granularity respected by the calendar plugin is reflected here too > cur_date_page = calplug.path_from_date(...) > > In the first pluginmanger attempt, the default values are seen not the > values in my preferences.conf > in the second attempt with configmanger, I see all the sections in my > .conf (included a bogus [FooBar] section) but all the dictionaries are > empty. > > > I think I am missing something obvious. Any hints? > > > As an aside, what is the best way to debug zim plugins? Currently, I make > a change, sprinkling in raise Exception(prefs) and restart zim. > > > Thanks! > Will > > > _______________________________________________ > Mailing list: https://launchpad.net/~zim-wiki > Post to : email@example.com > Unsubscribe : https://launchpad.net/~zim-wiki > More help : https://help.launchpad.net/ListHelp >
_______________________________________________ Mailing list: https://launchpad.net/~zim-wiki Post to : firstname.lastname@example.org Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp