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