Add CLIManager.user attribute and __init__ param
Instead of initializing self.user, ArgHandler now aliases the sessionmanager's one. svn: r23060
This commit is contained in:
parent
8d867ec2a5
commit
8bdb301958
@ -152,15 +152,11 @@ class ArgHandler(object):
|
||||
|
||||
def __init__(self, dbstate, parser, sessionmanager,
|
||||
errorfunc=None, gui=False):
|
||||
from .user import User
|
||||
|
||||
self.dbstate = dbstate
|
||||
self.sm = sessionmanager
|
||||
self.errorfunc = errorfunc
|
||||
self.gui = gui
|
||||
self.user = User(error=self.__error,
|
||||
auto_accept=parser.auto_accept,
|
||||
quiet=parser.quiet)
|
||||
self.user = sessionmanager.user
|
||||
if self.gui:
|
||||
self.actions = []
|
||||
self.list = False
|
||||
|
@ -213,7 +213,7 @@ class CLIManager(object):
|
||||
Aim is to manage a dbstate on which to work (load, unload), and interact
|
||||
with the plugin session
|
||||
"""
|
||||
def __init__(self, dbstate, setloader):
|
||||
def __init__(self, dbstate, setloader, user):
|
||||
self.dbstate = dbstate
|
||||
if setloader:
|
||||
self.db_loader = CLIDbLoader(self.dbstate)
|
||||
@ -221,6 +221,7 @@ class CLIManager(object):
|
||||
self.db_loader = None
|
||||
self.file_loaded = False
|
||||
self._pmgr = BasePluginManager.get_instance()
|
||||
self.user = user
|
||||
|
||||
def open_activate(self, path):
|
||||
"""
|
||||
@ -335,8 +336,14 @@ def startcli(errors, argparser):
|
||||
|
||||
#we need to keep track of the db state
|
||||
dbstate = DbState()
|
||||
|
||||
#we need a manager for the CLI session
|
||||
climanager = CLIManager(dbstate, True)
|
||||
from .user import User
|
||||
user=User(error=self.__error,
|
||||
auto_accept=argparser.auto_accept,
|
||||
quiet=argparser.quiet)
|
||||
climanager = CLIManager(dbstate, setloader=True, user=user)
|
||||
|
||||
#load the plugins
|
||||
climanager.do_reg_plugins(dbstate, uistate=None)
|
||||
# handle the arguments
|
||||
|
@ -43,7 +43,7 @@ def import_as_dict(filename, user=None):
|
||||
user = User()
|
||||
db = DictionaryDb()
|
||||
dbstate = DbState()
|
||||
climanager = CLIManager(dbstate, False) # do not load db_loader
|
||||
climanager = CLIManager(dbstate, setloader=False, user=user)
|
||||
climanager.do_reg_plugins(dbstate, None)
|
||||
pmgr = BasePluginManager.get_instance()
|
||||
(name, ext) = os.path.splitext(os.path.basename(filename))
|
||||
|
@ -272,7 +272,8 @@ See the Gramps README documentation for installation prerequisites,
|
||||
typically located in /usr/share/doc/gramps.""") % glocale.lang)
|
||||
|
||||
dbstate = DbState()
|
||||
self.vm = ViewManager(dbstate, config.get("interface.view-categories"))
|
||||
self.vm = ViewManager(dbstate,
|
||||
config.get("interface.view-categories"))
|
||||
self.vm.init_interface()
|
||||
|
||||
#act based on the given arguments
|
||||
|
@ -273,13 +273,13 @@ class ViewManager(CLIManager):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, view_category_order):
|
||||
def __init__(self, dbstate, view_category_order, user = None):
|
||||
"""
|
||||
The viewmanager is initialised with a dbstate on which GRAMPS is
|
||||
working, and a fixed view_category_order, which is the order in which
|
||||
the view categories are accessible in the sidebar.
|
||||
"""
|
||||
CLIManager.__init__(self, dbstate, False)
|
||||
CLIManager.__init__(self, dbstate, setloader=False, user=user)
|
||||
if _GTKOSXAPPLICATION:
|
||||
self.macapp = QuartzApp.Application()
|
||||
|
||||
@ -304,7 +304,11 @@ class ViewManager(CLIManager):
|
||||
self.show_toolbar = config.get('interface.toolbar-on')
|
||||
self.fullscreen = config.get('interface.fullscreen')
|
||||
|
||||
self.__build_main_window()
|
||||
self.__build_main_window() # sets self.uistate
|
||||
if self.user is None:
|
||||
self.user = User(error=ErrorDialog,
|
||||
callback=self.uistate.pulse_progressbar,
|
||||
uistate=self.uistate)
|
||||
self.__connect_signals()
|
||||
if _GTKOSXAPPLICATION:
|
||||
self.macapp.ready()
|
||||
@ -1317,17 +1321,11 @@ class ViewManager(CLIManager):
|
||||
self.uistate.push_message(self.dbstate, _("Making backup..."))
|
||||
if include.get_active():
|
||||
from gramps.plugins.export.exportpkg import PackageWriter
|
||||
writer = PackageWriter(self.dbstate.db, filename,
|
||||
User(error=ErrorDialog,
|
||||
callback=self.uistate.pulse_progressbar,
|
||||
uistate=self.uistate))
|
||||
writer = PackageWriter(self.dbstate.db, filename, self.user)
|
||||
writer.export()
|
||||
else:
|
||||
from gramps.plugins.export.exportxml import XmlWriter
|
||||
writer = XmlWriter(self.dbstate.db,
|
||||
User(error=ErrorDialog,
|
||||
callback=self.uistate.pulse_progressbar,
|
||||
uistate=self.uistate),
|
||||
writer = XmlWriter(self.dbstate.db, self.user,
|
||||
strip_photos=0, compress=1)
|
||||
writer.write(filename)
|
||||
self.uistate.set_busy_cursor(False)
|
||||
|
@ -78,16 +78,21 @@ class ViewManager(CLIManager):
|
||||
"""
|
||||
Manages main widget by holding what state it is in.
|
||||
"""
|
||||
def __init__(self, dbstate):
|
||||
def __init__(self, dbstate, user = None):
|
||||
"""
|
||||
The viewmanager is initialised with a dbstate on which GRAMPS is
|
||||
working.
|
||||
"""
|
||||
self.__centralview = None
|
||||
CLIManager.__init__(self, dbstate, False)
|
||||
CLIManager.__init__(self, dbstate, setloader=False, user=user)
|
||||
self.db_loader = CLIDbLoader(self.dbstate)
|
||||
#there is one DeclarativeEngine for global settings
|
||||
self.__build_main_window()
|
||||
from .questiondialog import ErrorDialog
|
||||
if self.user is None:
|
||||
self.user = User(error=ErrorDialog,
|
||||
callback=self.uistate.pulse_progressbar,
|
||||
uistate=self.uistate)
|
||||
|
||||
def __build_main_window(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user