3986: Interface for running code not associated with a plugin type: this passes dbstate and uistate to a load_on_reg function/class if a library has it, and it is marked as load_on_reg
svn: r15454
This commit is contained in:
parent
8ca80428a5
commit
4ce41d4656
@ -282,12 +282,13 @@ class CLIManager(object):
|
|||||||
RecentFiles.recent_files(filename, name)
|
RecentFiles.recent_files(filename, name)
|
||||||
self.file_loaded = True
|
self.file_loaded = True
|
||||||
|
|
||||||
def do_reg_plugins(self):
|
def do_reg_plugins(self, dbstate, uistate):
|
||||||
"""
|
"""
|
||||||
Register the plugins at initialization time.
|
Register the plugins at initialization time.
|
||||||
"""
|
"""
|
||||||
self._pmgr.reg_plugins(const.PLUGINS_DIR)
|
self._pmgr.reg_plugins(const.PLUGINS_DIR, dbstate, uistate)
|
||||||
self._pmgr.reg_plugins(const.USER_PLUGINS, append=False)
|
self._pmgr.reg_plugins(const.USER_PLUGINS, dbstate, uistate,
|
||||||
|
append=False)
|
||||||
|
|
||||||
def startcli(errors, argparser):
|
def startcli(errors, argparser):
|
||||||
"""
|
"""
|
||||||
@ -312,7 +313,7 @@ def startcli(errors, argparser):
|
|||||||
#we need a manager for the CLI session
|
#we need a manager for the CLI session
|
||||||
climanager = CLIManager(dbstate, True)
|
climanager = CLIManager(dbstate, True)
|
||||||
#load the plugins
|
#load the plugins
|
||||||
climanager.do_reg_plugins()
|
climanager.do_reg_plugins(dbstate, uistate=None)
|
||||||
# handle the arguments
|
# handle the arguments
|
||||||
from arghandler import ArgHandler
|
from arghandler import ArgHandler
|
||||||
handler = ArgHandler(dbstate, argparser, climanager)
|
handler = ArgHandler(dbstate, argparser, climanager)
|
||||||
|
@ -96,7 +96,7 @@ class BasePluginManager(object):
|
|||||||
self.__registereddir_set = set()
|
self.__registereddir_set = set()
|
||||||
self.__loaded_plugins = {}
|
self.__loaded_plugins = {}
|
||||||
|
|
||||||
def reg_plugins(self, direct, append=True):
|
def reg_plugins(self, direct, dbstate=None, uistate=None, append=True):
|
||||||
"""
|
"""
|
||||||
Searches the specified directory, and registers python plugin that
|
Searches the specified directory, and registers python plugin that
|
||||||
are being defined in gpr.py files.
|
are being defined in gpr.py files.
|
||||||
@ -128,6 +128,8 @@ class BasePluginManager(object):
|
|||||||
# load plugins that request to be loaded on startup
|
# load plugins that request to be loaded on startup
|
||||||
for plugin in self.__pgr.filter_load_on_reg():
|
for plugin in self.__pgr.filter_load_on_reg():
|
||||||
mod = self.load_plugin(plugin)
|
mod = self.load_plugin(plugin)
|
||||||
|
if hasattr(mod, "load_on_reg"):
|
||||||
|
mod.load_on_reg(dbstate, uistate)
|
||||||
|
|
||||||
def is_loaded(self, pdata_id):
|
def is_loaded(self, pdata_id):
|
||||||
"""
|
"""
|
||||||
|
@ -257,7 +257,7 @@ class ViewManager(CLIManager):
|
|||||||
self.__build_main_window()
|
self.__build_main_window()
|
||||||
self.__connect_signals()
|
self.__connect_signals()
|
||||||
|
|
||||||
self.do_reg_plugins()
|
self.do_reg_plugins(self.dbstate, self.uistate)
|
||||||
#plugins loaded now set relationship class
|
#plugins loaded now set relationship class
|
||||||
self.rel_class = Relationship.get_relationship_calculator()
|
self.rel_class = Relationship.get_relationship_calculator()
|
||||||
self.uistate.set_relationship_class()
|
self.uistate.set_relationship_class()
|
||||||
@ -646,14 +646,14 @@ class ViewManager(CLIManager):
|
|||||||
|
|
||||||
self.uistate.push_message(self.dbstate, _('Ready'))
|
self.uistate.push_message(self.dbstate, _('Ready'))
|
||||||
|
|
||||||
def do_reg_plugins(self):
|
def do_reg_plugins(self, dbstate, uistate):
|
||||||
"""
|
"""
|
||||||
Register the plugins at initialization time. The plugin status window
|
Register the plugins at initialization time. The plugin status window
|
||||||
is opened on an error if the user has requested.
|
is opened on an error if the user has requested.
|
||||||
"""
|
"""
|
||||||
# registering plugins
|
# registering plugins
|
||||||
self.uistate.status_text(_('Registering plugins...'))
|
self.uistate.status_text(_('Registering plugins...'))
|
||||||
error = CLIManager.do_reg_plugins(self)
|
error = CLIManager.do_reg_plugins(self, dbstate, uistate)
|
||||||
|
|
||||||
# get to see if we need to open the plugin status window
|
# get to see if we need to open the plugin status window
|
||||||
if error and config.get('behavior.pop-plugin-status'):
|
if error and config.get('behavior.pop-plugin-status'):
|
||||||
|
Loading…
Reference in New Issue
Block a user