Allow special quick views to receive additional arguments
svn: r13518
This commit is contained in:
parent
535abebc50
commit
b31acf707d
@ -122,7 +122,12 @@ def get_quick_report_list(qv_category=None):
|
|||||||
return names
|
return names
|
||||||
|
|
||||||
def run_quick_report_by_name(dbstate, uistate, report_name, handle,
|
def run_quick_report_by_name(dbstate, uistate, report_name, handle,
|
||||||
container=None):
|
container=None, **kwargs):
|
||||||
|
"""
|
||||||
|
Run a QuickView by name.
|
||||||
|
**kwargs provides a way of passing special quick views additional
|
||||||
|
arguments.
|
||||||
|
"""
|
||||||
report = None
|
report = None
|
||||||
pmgr = GuiPluginManager.get_instance()
|
pmgr = GuiPluginManager.get_instance()
|
||||||
for pdata in pmgr.get_reg_quick_reports():
|
for pdata in pmgr.get_reg_quick_reports():
|
||||||
@ -131,7 +136,7 @@ def run_quick_report_by_name(dbstate, uistate, report_name, handle,
|
|||||||
break
|
break
|
||||||
if report:
|
if report:
|
||||||
return run_report(dbstate, uistate, report.category,
|
return run_report(dbstate, uistate, report.category,
|
||||||
handle, report, container=container)
|
handle, report, container=container, **kwargs)
|
||||||
else:
|
else:
|
||||||
raise AttributeError, ("No such quick report '%s'" % report_name)
|
raise AttributeError, ("No such quick report '%s'" % report_name)
|
||||||
|
|
||||||
@ -165,15 +170,17 @@ def run_quick_report_by_name_direct(report_name, database, document, handle):
|
|||||||
else:
|
else:
|
||||||
raise AttributeError, ("No such quick report id = '%s'" % report_name)
|
raise AttributeError, ("No such quick report id = '%s'" % report_name)
|
||||||
|
|
||||||
def run_report(dbstate, uistate, category, handle, pdata, container=None):
|
def run_report(dbstate, uistate, category, handle, pdata, container=None,
|
||||||
|
**kwargs):
|
||||||
"""
|
"""
|
||||||
Run a Quick Report.
|
Run a Quick Report.
|
||||||
Optionally container can be passed, rather than putting the report
|
Optionally container can be passed, rather than putting the report
|
||||||
in a new window.
|
in a new window.
|
||||||
|
**kwargs are only used for special quick views that allow additional
|
||||||
|
arguments, and that are run by run_quick_report_by_name().
|
||||||
"""
|
"""
|
||||||
from docgen import TextBufDoc
|
from docgen import TextBufDoc
|
||||||
from Simple import make_basic_stylesheet
|
from Simple import make_basic_stylesheet
|
||||||
container = None
|
|
||||||
pmgr = GuiPluginManager.get_instance()
|
pmgr = GuiPluginManager.get_instance()
|
||||||
mod = pmgr.load_plugin(pdata)
|
mod = pmgr.load_plugin(pdata)
|
||||||
if not mod:
|
if not mod:
|
||||||
@ -210,11 +217,11 @@ def run_report(dbstate, uistate, category, handle, pdata, container=None):
|
|||||||
if obj:
|
if obj:
|
||||||
if container:
|
if container:
|
||||||
result = d.open("", container=container)
|
result = d.open("", container=container)
|
||||||
func(dbstate.db, d, obj)
|
func(dbstate.db, d, obj, **kwargs)
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
d.open("")
|
d.open("")
|
||||||
retval = func(dbstate.db, d, obj)
|
retval = func(dbstate.db, d, obj, **kwargs)
|
||||||
d.close()
|
d.close()
|
||||||
return retval
|
return retval
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user