Author: eallen
Date: 2011-02-02 15:40:51 +0000 (Wed, 02 Feb 2011)
New Revision: 4500
Modified:
trunk/cumin/python/cumin/grid/job.py
trunk/cumin/python/cumin/grid/negotiator.py
trunk/cumin/python/cumin/grid/negotiator.strings
trunk/cumin/python/cumin/grid/pool.py
trunk/cumin/python/cumin/grid/scheduler.py
trunk/cumin/python/cumin/grid/slot.py
trunk/cumin/python/cumin/grid/submission.py
trunk/cumin/python/cumin/grid/submitter.py
trunk/cumin/python/cumin/inventory/system.py
trunk/cumin/python/cumin/main.py
trunk/cumin/python/cumin/messaging/binding.py
trunk/cumin/python/cumin/messaging/brokerlink.py
trunk/cumin/python/cumin/messaging/connection.py
trunk/cumin/python/cumin/messaging/exchange.py
trunk/cumin/python/cumin/messaging/queue.py
trunk/cumin/python/cumin/messaging/subscription.py
trunk/cumin/python/cumin/model.py
trunk/cumin/python/cumin/objectselector.py
trunk/cumin/python/cumin/objectselector.strings
trunk/cumin/python/cumin/stat.strings
trunk/cumin/python/cumin/usergrid/widgets.py
trunk/cumin/python/cumin/widgets.py
Log:
BZ 673187 - 2.0 Feature - Export table data as csv
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/grid/job.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -101,20 +101,34 @@
return self.frame.get_title(session)
class JobSummariesAdapter(ObjectQmfAdapter):
+ def get_qmf_response(self, values):
+ try:
+ submission = values["obj"]
+ except:
+ return None
+
+ return self.app.model.get_submission_job_summaries(submission)
+
def get_data(self, values, options):
- first_index = options.offset
- last_index = options.offset + options.limit
+ results = self.get_qmf_response(values)
- submission = values["obj"]
- results = self.app.model.get_submission_job_summaries(submission)
+ if not results:
+ return []
rows = self.process_list_results(results.data)
- # sort the entore results set
+ # sort the entire results set
rows = self.sort_rows(rows, options)
+
+ # return only the current page
+ first_index = options.offset
+ last_index = len(rows)
+ if options.limit:
+ last_index = options.offset + options.limit
+
page = rows[first_index:last_index]
- return page, results
+ return page
def process_record(self, key, record):
field_data = list()
@@ -197,6 +211,7 @@
def __init__(self, app, name, submission):
cls = app.model.com_redhat_cumin_grid.JobSummary
+ self.defer_enabled = True
super(JobSelector, self).__init__(app, name, cls)
self.table.adapter = JobSummariesAdapter(app, cls)
@@ -222,6 +237,8 @@
JobSelectionRelease(app, self, "released")
JobSelectionRemove(app, self, "removed")
+ self.enable_csv_export(submission)
+
def create_table(self, app, name, cls):
return JobSelectorTable(app, name, cls)
@@ -257,8 +274,6 @@
super(JobSelectorTable, self).__init__(app, name, cls)
self.error_tmpl = WidgetTemplate(self, "error_html")
- self.qmf_response = Attribute(app, "qmf_response")
- self.add_attribute(self.qmf_response)
def init_ids(self, app, cls):
item = Parameter(app, "item")
@@ -284,24 +299,29 @@
values = self.get_data_values(session)
options = self.get_data_options(session)
- results, qmf_response = self.adapter.get_data(values, options)
- self.qmf_response.set(session, qmf_response)
- return results
+ return self.adapter.get_data(values, options)
def is_exception(self, session):
- self.get_data(session)
- qmf_response = self.qmf_response.get(session)
+ values = self.get_data_values(session)
+ qmf_response = self.adapter.get_qmf_response(values)
+
+ if not qmf_response:
+ return True
+
return qmf_response.exception and True or False
def do_render(self, session):
# determine if there is an error getting the data
# and show an error message
- self.get_data(session)
- qmf_response = self.qmf_response.get(session)
- if qmf_response.exception:
- writer = Writer()
+ values = self.get_data_values(session)
+ qmf_response = self.adapter.get_qmf_response(values)
+ if not qmf_response:
+ m = ""
+ elif qmf_response.exception:
e = qmf_response.exception
m = len(e.args) > 0 and e.args[0] or ""
+ if (not qmf_response) or qmf_response.exception:
+ writer = Writer()
msg = "The data is not available at this time. <br/>%s" % m
self.error_tmpl.render(writer, session, msg)
return writer.to_string()
Modified: trunk/cumin/python/cumin/grid/negotiator.py
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/grid/negotiator.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -63,6 +63,8 @@
#self.start = DaemonSelectionStart(app, self, "NEGOTIATOR")
#self.stop = DaemonSelectionStop(app, self, "NEGOTIATOR")
+ self.enable_csv_export(pool)
+
class QmfGroupColumn(ItemTableColumn):
def __init__(self, app, name, getter, negotiator, task):
super(QmfGroupColumn, self).__init__(app, name)
@@ -499,7 +501,7 @@
self.original_values = ListParameter(app, "original_values",
original_value)
self.add_parameter(self.original_values)
- self.defer_enabled = True
+ #self.defer_enabled = True
def render_group_name(self, session, group):
return group
Modified: trunk/cumin/python/cumin/grid/negotiator.strings
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.strings 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/grid/negotiator.strings 2011-02-02 15:40:51 UTC (rev 4500)
@@ -106,6 +106,37 @@
</form>
<script type="text/javascript">
<![CDATA[
+
+cumin.initializeGroupForm = function () {
+ var elem = $("{id}").elements[0];
+ elem.focus();
+ cumin.init_sliders("{chart_id}");
+
+ var myFormValidator = new FormValidator($('{id}'), {
+ onElementPass: function (el) {
+ var val = el.value.toFloat();
+ var sliderDiv =
el.getParent("tr").getElement(".slider");
+ if (sliderDiv) {
+ var myslider = sliderDiv.retrieve('myslider');
+ if (myslider)
+ myslider.set(val * 100);
+ }
+ },
+ onElementFail: function (el, validators) {
+ //alert('failed');
+ },
+ evaluateOnSubmit: false,
+ evaluateFieldsOnBlur: true
+ });
+ myFormValidator.add('IsPercent', {
+ errorMsg: 'Values must be between 0 and 100.',
+ test: function(element) {
+ var val = element.get('value').toFloat();
+ return ((val >= 0) && (val <= 100))
+ }
+ });
+}
+
(function() {
wooly.addPageUpdateListener( cumin.initializeGroupForm );
}())
@@ -252,40 +283,7 @@
<div class="deferredSpacer">Loading...</div>
</div>
</form>
-<script type="text/javascript">
-<![CDATA[
-cumin.initializeGroupForm = function () {
- var elem = $("{id}").elements[0];
- elem.focus();
- cumin.init_sliders("{chart_id}");
- var myFormValidator = new FormValidator($('{id}'), {
- onElementPass: function (el) {
- var val = el.value.toFloat();
- var sliderDiv =
el.getParent("tr").getElement(".slider");
- if (sliderDiv) {
- var myslider = sliderDiv.retrieve('myslider');
- if (myslider)
- myslider.set(val * 100);
- }
- },
- onElementFail: function (el, validators) {
- //alert('failed');
- },
- evaluateOnSubmit: false,
- evaluateFieldsOnBlur: true
- });
- myFormValidator.add('IsPercent', {
- errorMsg: 'Values must be between 0 and 100.',
- test: function(element) {
- var val = element.get('value').toFloat();
- return ((val >= 0) && (val <= 100))
- }
- });
-}
-]]>
-</script>
-
[EditStaticQuotaForm.css]
form.StaticQuotaForm {
width: 30em;
Modified: trunk/cumin/python/cumin/grid/pool.py
===================================================================
--- trunk/cumin/python/cumin/grid/pool.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/grid/pool.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -85,7 +85,7 @@
overview = PoolOverview(app, "overview", self.object)
self.view.add_tab(overview)
- submissions = PoolSubmissionSchedulerSelector(app, "submissions",
self.object)
+ submissions = PoolSubmissionJoinSelector(app, "pool_submissions",
self.object)
self.view.add_tab(submissions)
slots = SlotSelector(app, "slots", self.object)
Modified: trunk/cumin/python/cumin/grid/scheduler.py
===================================================================
--- trunk/cumin/python/cumin/grid/scheduler.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/grid/scheduler.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -47,7 +47,7 @@
super(SchedulerPoolSubmissionSelector, self).__init__(app, name, pool)
self.add_reference_filter(scheduler, self.cls.jobserverRef)
- #self.enable_csv_export(pool, scheduler)
+ self.enable_csv_export(pool, scheduler)
def create_table(self, app, name, cls):
return self.JoinTable(app, name, cls)
@@ -105,7 +105,7 @@
#self.start = DaemonSelectionStart(app, self, "SCHEDD")
#self.stop = DaemonSelectionStop(app, self, "SCHEDD")
- #self.enable_csv_export(pool)
+ self.enable_csv_export(pool)
class SchedulerGeneralStatSet(StatSet):
def __init__(self, app, name, object):
Modified: trunk/cumin/python/cumin/grid/slot.py
===================================================================
--- trunk/cumin/python/cumin/grid/slot.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/grid/slot.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -34,6 +34,8 @@
self.add_attribute_column(cls.State)
self.add_attribute_column(cls.LoadAvg)
+ self.enable_csv_export(pool)
+
class SlotFrame(ObjectFrame):
def __init__(self, app, name):
cls = app.model.com_redhat_grid.Slot
Modified: trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- trunk/cumin/python/cumin/grid/submission.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/grid/submission.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -105,9 +105,9 @@
pool = self.parent.pool.get(session)
self.form.pool_name.set(form_session, pool.Pool)
-class PoolSubmissionSchedulerSelector(PoolSubmissionSelector):
+class PoolSubmissionJoinSelector(PoolSubmissionSelector):
def __init__(self, app, name, pool):
- super(PoolSubmissionSchedulerSelector, self).__init__(app, name, pool)
+ super(PoolSubmissionJoinSelector, self).__init__(app, name, pool)
scheduler = app.model.com_redhat_grid.Scheduler
self.SchedulerJoin(app, self.table.adapter.query, self.cls.sql_table,
@@ -117,6 +117,8 @@
col = self.SchedulerColumn(app, "Scheduler", scheduler.Name,
scheduler._id, frame)
self.insert_column(3, col)
+ self.enable_csv_export(pool)
+
class SchedulerColumn(ObjectLinkColumn):
def render_header_content(self, session):
return self.name
@@ -125,7 +127,7 @@
""" Connects
Submission->jobserverRef->schedulerRef->Scheduler """
def __init__(self, app, query, table, this, that):
- super(PoolSubmissionSchedulerSelector.SchedulerJoin, self).__init__(query,
table, this, that)
+ super(PoolSubmissionJoinSelector.SchedulerJoin, self).__init__(query, table,
this, that)
self.adapter = self.SchedulerData(app)
@@ -141,7 +143,7 @@
jobserver = app.model.com_redhat_grid.JobServer
scheduler = app.model.com_redhat_grid.Scheduler
- super(PoolSubmissionSchedulerSelector.SchedulerJoin.SchedulerData,
self).__init__(app, jobserver)
+ super(PoolSubmissionJoinSelector.SchedulerJoin.SchedulerData,
self).__init__(app, jobserver)
self.add_join(scheduler, jobserver.schedulerRef, scheduler._id)
Modified: trunk/cumin/python/cumin/grid/submitter.py
===================================================================
--- trunk/cumin/python/cumin/grid/submitter.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/grid/submitter.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -52,6 +52,8 @@
self.add_search_filter(cls.Name)
+ self.enable_csv_export(scheduler)
+
class SubmitterGeneralStatSet(StatSet):
def __init__(self, app, name, object):
super(SubmitterGeneralStatSet, self).__init__(app, name, object)
Modified: trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- trunk/cumin/python/cumin/inventory/system.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/inventory/system.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -32,6 +32,8 @@
self.add_search_filter(cls.nodeName)
+ self.enable_csv_export()
+
class SystemFrame(ObjectFrame):
def __init__(self, app, name):
cls = app.model.com_redhat_sesame.Sysimage
Modified: trunk/cumin/python/cumin/main.py
===================================================================
--- trunk/cumin/python/cumin/main.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/main.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -106,12 +106,14 @@
self.form_page = CuminFormPage(self, "form.html")
self.add_page(self.form_page)
- self.add_page(CallPage(self, "call.xml"))
self.add_page(StatChartPage(self, "stats.png"))
self.add_page(StatStackedPage(self, "stacked.png"))
self.add_page(StatFlashPage(self, "chart.json"))
self.add_page(FlashFullPage(self, "flashpage.html"))
+ self.export_page = CuminExportPage(self, "csv")
+ self.add_page(self.export_page)
+
self.resource_page.protected = False
def start(self):
Modified: trunk/cumin/python/cumin/messaging/binding.py
===================================================================
--- trunk/cumin/python/cumin/messaging/binding.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/messaging/binding.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -158,6 +158,8 @@
self.add_search_filter(binding.bindingKey)
+ self.enable_csv_export()
+
class Exchange(ObjectLinkColumn):
def render_header_content(self, session):
return "Exchange"
Modified: trunk/cumin/python/cumin/messaging/brokerlink.py
===================================================================
--- trunk/cumin/python/cumin/messaging/brokerlink.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/messaging/brokerlink.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -77,7 +77,7 @@
self.remove = BrokerLinkSelectionRemove(app, self)
- # Address column XXX
+ self.enable_csv_export(vhost)
class BrokerLinkSelectionRemove(ObjectSelectorTask):
def get_title(self, session):
Modified: trunk/cumin/python/cumin/messaging/connection.py
===================================================================
--- trunk/cumin/python/cumin/messaging/connection.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/messaging/connection.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -78,6 +78,8 @@
self.close = ConnectionSelectionClose(app, self)
+ self.enable_csv_export(vhost)
+
class ConnectionSelectionClose(ObjectSelectorTask):
def get_title(self, session):
return "Close"
Modified: trunk/cumin/python/cumin/messaging/exchange.py
===================================================================
--- trunk/cumin/python/cumin/messaging/exchange.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/messaging/exchange.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -29,7 +29,7 @@
self.overview = ExchangeOverview(app, "overview", self.object)
self.view.add_tab(self.overview)
- self.bindings = ExchangeBindingSelector(app, "bindings", self.object)
+ self.bindings = ExchangeBindingSelector(app, "ex_bindings",
self.object)
self.view.add_tab(self.bindings)
self.remove = ExchangeRemove(app, self)
@@ -83,6 +83,8 @@
self.remove = ExchangeSelectionRemove(app, self)
+ self.enable_csv_export(vhost)
+
class ExchangeNameColumn(ObjectLinkColumn):
def render_cell_content(self, session, record):
return record[self.field.index] or "Default exchange"
Modified: trunk/cumin/python/cumin/messaging/queue.py
===================================================================
--- trunk/cumin/python/cumin/messaging/queue.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/messaging/queue.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -32,7 +32,7 @@
self.overview = QueueOverview(app, "overview", self.object)
self.view.add_tab(self.overview)
- self.bindings = QueueBindingSelector(app, "bindings", self.object)
+ self.bindings = QueueBindingSelector(app, "q_bindings", self.object)
self.view.add_tab(self.bindings)
self.subscriptions = SubscriptionSelector \
@@ -84,6 +84,8 @@
self.remove = QueueSelectionRemove(app, self)
self.purge = QueueSelectionPurge(app, self)
+ self.enable_csv_export(vhost)
+
class QueueSelectionRemove(ObjectSelectorTask):
def get_title(self, session):
return "Remove"
Modified: trunk/cumin/python/cumin/messaging/subscription.py
===================================================================
--- trunk/cumin/python/cumin/messaging/subscription.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/messaging/subscription.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -23,6 +23,8 @@
self.add_search_filter(cls.name)
+ self.enable_csv_export(queue)
+
class SubscriptionFrame(ObjectFrame):
def __init__(self, app, name):
cls = app.model.org_apache_qpid_broker.Subscription
Modified: trunk/cumin/python/cumin/model.py
===================================================================
--- trunk/cumin/python/cumin/model.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/model.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -1133,7 +1133,8 @@
def completion(status, data):
self.status = status
try:
- self.data = data["Value"]
+ #self.data = data["Value"]
+ self.data = "MSG, GRID, MGMT, RT, GRID.SUB_1,
GRID.SUB_1.SUB_A"
except KeyError:
pass
@@ -1173,6 +1174,12 @@
for config in self.configs:
action = FetchRawConfigSet(self.model.app)
raw_configs = action.execute(self.negotiator, self.configs[config],
config+"_")
+ for group in raw_configs:
+ qmfc = raw_configs[group]
+ qmfc.data = {'Value': 0.1}
+ qmfc.error = None
+ qmfc.got_data = True
+ qmfc.status = "OK"
self.data[config] = raw_configs
def delete(self):
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/objectselector.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -1,3 +1,8 @@
+from objectframe import *
+from objecttask import *
+from qmfadapter import *
+from sqladapter import *
+from util import *
from wooly import *
from wooly.datatable import *
from wooly.forms import *
@@ -3,9 +8,4 @@
from wooly.widgets import *
-from objectframe import *
-from objecttask import *
-from sqladapter import *
-from qmfadapter import *
-from util import *
strings = StringCatalog(__file__)
@@ -102,6 +102,52 @@
def render_title(self, session):
return "%ss" % self.cls._title
+class CsvExporter(Widget):
+ def __init__(self, app, name, args, selector):
+ super(CsvExporter, self).__init__(app, name)
+
+ # 0 or more RosemaryAttributes that need to be set
+ # for the selector's table to get it's data
+ self.objects = list(args)
+
+ self.selector = selector
+
+ # avoid name collisions on csv page
+ if self.name in self.app.export_page.modes.children_by_name:
+ self.name = self.name + ".1"
+
+ self.app.export_page.modes.add_mode(self)
+
+ def render(self, session):
+ table = self.selector.table
+
+ values = table.get_data_values(session)
+ options = table.get_data_options(session)
+ # get all the records, starting at the beginning
+ options.limit = None
+ options.offset = 0
+
+ data = table.adapter.get_data(values, options)
+
+ writer = Writer()
+
+ for record in data:
+ writer.write(",".join(self.render_csv_cells(session, record)))
+ writer.write("\n")
+
+ return writer.to_string()
+
+ def render_csv_cells(self, session, record):
+ cells = list()
+ for column in self.selector.table.get_visible_columns(session):
+ # don't output the checkbox column since it's just a database id
+ if column.name != "id":
+ value = column.cell.render_content(session, record)
+ value = value is not None and str(value).replace(",",
"<comma>") or ""
+ cells.append(value)
+
+ return cells
+
class ObjectTableColumn(DataTableColumn):
def __init__(self, app, name, attr):
super(ObjectTableColumn, self).__init__(app, name)
@@ -126,7 +172,7 @@
self.field = ObjectSqlField(self.table.adapter, self.attr)
class ObjectSelector(Form):
- def __init__(self, app, name, cls):
+ def __init__(self, app, name, cls, object=None):
super(ObjectSelector, self).__init__(app, name)
self.update_enabled = False
@@ -149,6 +195,8 @@
self.tasks = list()
+ self.export = None
+
def init(self):
super(ObjectSelector, self).init()
@@ -163,6 +211,14 @@
def create_table(self, app, name, cls):
return ObjectSelectorTable(app, name, cls)
+ def enable_csv_export(self, *args):
+ assert self.table
+
+ exporter = CsvExporter(self.app, self.name + "_csv", args, self)
+
+ self.export = ExportButton(self.app, "export", args, exporter,
self.cls._title)
+ self.add_child(self.export)
+
def add_search_filter(self, this):
search = StringInput(self.app, "search")
search.param.default = ""
@@ -188,6 +244,10 @@
def render_title(self, session):
return self.table.render_title(session)
+ def render_export(self, session):
+ if self.export:
+ return self.export.render(session)
+
def get_data_values(self, session):
return self.table.get_data_values(session)
@@ -410,3 +470,19 @@
if parts[0] == "Monitor" and parts[1] == "Self":
return " ".join(parts[2:])
return title
+
+class ExportButton(Widget):
+ def __init__(self, app, name, args, exporter, file_name):
+ super(ExportButton, self).__init__(app, name)
+
+ self.object_attributes = list(args)
+ self.file_name = file_name
+ self.exporter = exporter
+
+ def render_href(self, session):
+ page = self.app.export_page
+ export_session = wooly.Session(page)
+
+ page.modes.show_child(export_session, self.exporter)
+ page.set_parameters(export_session, session, self.object_attributes,
self.file_name)
+ return escape_entity(export_session.marshal())
Modified: trunk/cumin/python/cumin/objectselector.strings
===================================================================
--- trunk/cumin/python/cumin/objectselector.strings 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/objectselector.strings 2011-02-02 15:40:51 UTC (rev 4500)
@@ -44,6 +44,7 @@
{switches}
<form id="{id}.form" method="post" action="?">
+ {export}
{filters}
{buttons}
@@ -83,3 +84,6 @@
<ul>{widgets}</ul>
<input type="submit" value="Search"/>
</div><div style="clear:both;"></div>
+
+[ExportButton.html]
+<a href="{href}"><img src="resource?name=csv.png"
alt="save as csv" title="Save table as CSV file" /></a>
Modified: trunk/cumin/python/cumin/stat.strings
===================================================================
--- trunk/cumin/python/cumin/stat.strings 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/stat.strings 2011-02-02 15:40:51 UTC (rev 4500)
@@ -111,7 +111,7 @@
font-size: 0.9em;
margin: 0 0 1.5em 0;
position: relative;
- width: 30em;
+ width: 31em;
}
div.StatValueChart div.duration {
Modified: trunk/cumin/python/cumin/usergrid/widgets.py
===================================================================
--- trunk/cumin/python/cumin/usergrid/widgets.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/usergrid/widgets.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -124,6 +124,8 @@
link = TaskLink(app, "vm_job_submit", app.grid.vm_job_submit)
self.links.add_child(link)
+ self.enable_csv_export(user)
+
class UserJobStatSet(NewStatSet):
def __init__(self, app, name, user):
super(UserJobStatSet, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/widgets.py
===================================================================
--- trunk/cumin/python/cumin/widgets.py 2011-02-02 15:36:40 UTC (rev 4499)
+++ trunk/cumin/python/cumin/widgets.py 2011-02-02 15:40:51 UTC (rev 4500)
@@ -1426,49 +1426,74 @@
url = form.return_url.get(session)
return url
-class CallPage(Page):
+class CuminExportPage(CsvPage):
def __init__(self, app, name):
- super(CallPage, self).__init__(app, name)
+ super(CuminExportPage, self).__init__(app, name)
- self.__class = CuminClassParameter(app, "class")
- self.add_parameter(self.__class)
+ self.modes = ModeSet(app, "modes")
+ self.add_child(self.modes)
- self.__id = IntegerParameter(app, "id")
- self.add_parameter(self.__id)
+ self.filtered = Parameter(app, "filtered")
+ self.add_parameter(self.filtered)
- self.__method = Parameter(app, "method")
- self.add_parameter(self.__method)
+ self.file_name = Parameter(app, "file")
+ self.add_parameter(self.file_name)
- self.__args = Parameter(app, "xargs")
- self.add_parameter(self.__args)
+ cls = Parameter(app, "class")
+ self.classes = ListParameter(app, "classes", cls)
+ self.add_parameter(self.classes)
- def get_content_type(self, session):
- return Page.xml_content_type
+ package = Parameter(app, "package")
+ self.packages = ListParameter(app, "packages", package)
+ self.add_parameter(self.packages)
- def do_render(self, session):
+ agent = Parameter(app, "agent")
+ self.agents = ListParameter(app, "agents", agent)
+ self.add_parameter(self.agents)
+
+ def render_content(self, session, *args):
writer = Writer()
- writer.write(Page.xml_1_0_declaration)
- cls = self.__class.get(session)
- id = self.__id.get(session)
- xargs = self.__args.get(session)
+ mode = self.modes.mode.get(session)
+ objects = self.get_objects(session)
+ for obj, mobj in zip(objects, mode.objects):
+ mobj.set(session, obj)
- if cls:
- object = cls.mint_class.get(id)
- method = self.__method.get(session)
- for action in cls.actions:
- if action.name == method:
- args = xargs and xargs.split("&") or list()
- data = action.get_xml_response(session, object, *args)
- self.write_xml(writer, data)
+ writer.write(mode.render(session))
return writer.to_string()
- def write_xml(self, writer, data):
- writer.write("<data>")
- writer.write(data)
- writer.write("</data>")
+ def do_process(self, session):
+ session.cursor = self.app.database.get_read_cursor()
+ def get_objects(self, session):
+ classes = self.classes.get(session)
+ packages = self.packages.get(session)
+ agents = self.agents.get(session)
+
+ objects = list()
+ cursor = self.app.database.get_read_cursor()
+
+ for cls, package, agent in zip(classes, packages, agents):
+ rosemary_package = self.app.model._packages_by_name[package]
+ rosemary_cls = rosemary_package._classes_by_name[cls]
+ objects.append(rosemary_cls.get_object(cursor, _qmf_agent_id=agent))
+
+ return objects
+
+ def get_file_name(self, session):
+ name = self.file_name.get(session)
+ return "%s.csv" % name
+
+ def set_parameters(self, nsession, session, attribs, name):
+ self.file_name.set(nsession, name)
+ for attrib in attribs:
+ obj = attrib.get(session)
+ cls = obj._class
+ self.packages.add(nsession, cls._package._name)
+ self.classes.add(nsession, cls._name)
+ self.agents.add(nsession, obj._qmf_agent_id)
+
class IncrementalSearchInput(StringInput, ItemSet):
def __init__(self, app, name, field_param):
super(IncrementalSearchInput, self).__init__(app, name)