r4531 - in trunk/cumin: . python/cumin/account
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-02-15 19:56:52 +0000 (Tue, 15 Feb 2011)
New Revision: 4531
Modified:
trunk/cumin/Makefile
trunk/cumin/python/cumin/account/widgets.py
trunk/cumin/python/cumin/account/widgets.strings
Log:
Add an "About the console" tab under "Your Account" in the UI.
Extend cumin/Makefile to allow the creation of a version file from
svn info or argumentn to make, allow optional distinction for local
development versions. Version file will also be created as part
of "make install".
BZ630544
Modified: trunk/cumin/Makefile
===================================================================
--- trunk/cumin/Makefile 2011-02-15 16:21:29 UTC (rev 4530)
+++ trunk/cumin/Makefile 2011-02-15 19:56:52 UTC (rev 4531)
@@ -1,12 +1,24 @@
-.phony: build install clean check
+.phony: build install clean check clean-version write-version mark-local version version-local
include ../etc/Makefile.common
+# Attempt to build a version from svn info if we don't already have one
+ifndef CUMIN_VERSION
+VERSION_REV = $(shell svn info .. 2> /dev/null | fgrep "Last Changed Rev:" | cut -d " " -f 4)
+endif
+
+# if CUMIN_VERSION wasn't passed in, and svn info worked, set CUMIN_VERSION
+ifneq ($(strip $(VERSION_REV)),)
+CUMIN_VERSION = 0.1.$(VERSION_REV)
+endif
+
+VERSION_FILE = $(CUMIN_HOME)/version
+
build:
python -m compileall -x '/\.svn' -f python
install: CUMIN_HOME := $(shell mktemp -d)
-install: build
+install: build version
install -d ${CUMIN_HOME}/bin
install -pm 0755 bin/cumin bin/cumin-* ${CUMIN_HOME}/bin
install -d ${CUMIN_HOME}/doc
@@ -29,8 +41,29 @@
bin/install-python-code ../parsley/python ${CUMIN_HOME}/python
find ${CUMIN_HOME} -type d
-clean: clean-python-files
+clean-version:
+ @ -rm -f $(VERSION_FILE)
+write-version: clean-version
+ifndef CUMIN_VERSION
+ @echo svn info failed, version file not created, this is okay
+else
+ @echo $(CUMIN_VERSION) > $(VERSION_FILE)
+ @chmod 0644 $(VERSION_FILE)
+endif
+
+mark-local:
+#if the file exists, allow the local mark to be applied
+ifeq ($(shell ls $(VERSION_FILE) 2> /dev/null),$(VERSION_FILE))
+ @echo local >> $(VERSION_FILE)
+endif
+
+version: write-version
+
+version-local: write-version mark-local
+
+clean: clean-python-files clean-version
+
check:
cumin-admin-test
cumin-data-test
Modified: trunk/cumin/python/cumin/account/widgets.py
===================================================================
--- trunk/cumin/python/cumin/account/widgets.py 2011-02-15 16:21:29 UTC (rev 4530)
+++ trunk/cumin/python/cumin/account/widgets.py 2011-02-15 19:56:52 UTC (rev 4531)
@@ -1,3 +1,5 @@
+import subprocess
+
from wooly import *
from wooly.widgets import *
from wooly.resources import *
@@ -32,6 +34,9 @@
self.settings = SettingsFrame(app, "main")
self.add_tab(self.settings)
+
+ self.about = AboutFrame(app, "about")
+ self.add_tab(self.about)
class SettingsFrame(Frame):
def __init__(self, app, name):
@@ -59,6 +64,42 @@
def render_content(self, sessino):
return "Change password"
+class AboutFrame(Frame):
+ def __init__(self, app, name):
+ super(AboutFrame, self).__init__(app, name)
+ content = AboutContent(app, "about_content")
+ self.add_child(content)
+
+ def render_title(self, session):
+ return "About the console"
+
+class AboutContent(Widget):
+ def __init__(self, app, name):
+ super(AboutContent, self).__init__(app, name)
+
+ self.version_string = ""
+ self.version_local = False
+
+ # Look for version info in our well-known file.
+ version_path = os.path.join(self.app.home, "version")
+ if os.path.isfile(version_path):
+ # Permission errors or corrupt file always possible
+ try:
+ f = open(version_path)
+ self.version_string = f.readline().strip()
+ self.version_local = f.readline().strip() == "local"
+ except:
+ pass
+
+ if len(self.version_string) == 0:
+ self.version_string = "Version has not been set"
+
+ def render_version(self, session):
+ res = self.version_string
+ if self.version_local:
+ res += ", devel instance"
+ return res
+
class LoginPage(HtmlPage):
def __init__(self, app, name):
super(LoginPage, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/account/widgets.strings
===================================================================
--- trunk/cumin/python/cumin/account/widgets.strings 2011-02-15 16:21:29 UTC (rev 4530)
+++ trunk/cumin/python/cumin/account/widgets.strings 2011-02-15 19:56:52 UTC (rev 4531)
@@ -75,3 +75,10 @@
[LoginForm.login_invalid]
<p class="login_invalid">The user name and password you entered do not
match any account.</p>
+
+[AboutContent.html]
+<div>
+<h3>Management console version</h3>
+{version}
+</div>
+
13 years, 3 months
r4530 - trunk/cumin/python/cumin
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-15 16:21:29 +0000 (Tue, 15 Feb 2011)
New Revision: 4530
Modified:
trunk/cumin/python/cumin/model.py
trunk/cumin/python/cumin/objectselector.py
Log:
Remove some debugging code.
Change the table search prompt
Modified: trunk/cumin/python/cumin/model.py
===================================================================
--- trunk/cumin/python/cumin/model.py 2011-02-15 15:47:59 UTC (rev 4529)
+++ trunk/cumin/python/cumin/model.py 2011-02-15 16:21:29 UTC (rev 4530)
@@ -1084,9 +1084,9 @@
def completion(status, data):
self.status = status
try:
- #self.data = data["Limits"]
- self.data = {'a':{'CURRENT': 11, 'MAX': 22},
- 'b':{'CURRENT': 3, 'MAX': 44}}
+ self.data = data["Limits"]
+ #self.data = {'a':{'CURRENT': 11, 'MAX': 22},
+ # 'b':{'CURRENT': 3, 'MAX': 44}}
except KeyError:
pass
@@ -1130,8 +1130,8 @@
def completion(status, data):
self.status = status
try:
- #self.data = data["Value"]
- self.data = "MSG, GRID, MGMT, RT, GRID.SUB_1, GRID.SUB_1.SUB_A"
+ self.data = data["Value"]
+ #self.data = "MSG, GRID, MGMT, RT, GRID.SUB_1, GRID.SUB_1.SUB_A"
except KeyError:
pass
@@ -1171,12 +1171,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"
+ #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 update_new(self, cursor):
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2011-02-15 15:47:59 UTC (rev 4529)
+++ trunk/cumin/python/cumin/objectselector.py 2011-02-15 16:21:29 UTC (rev 4530)
@@ -235,7 +235,7 @@
def add_search_filter(self, this):
search = StringInput(self.app, "search")
search.param.default = ""
- search.title = "Enter search term"
+ search.title = "Search in %s" % this.attr.title
self.table.add_like_filter(search.param, this)
self.filters.add_child(search)
13 years, 3 months
r4529 - trunk/cumin/bin
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-15 15:47:59 +0000 (Tue, 15 Feb 2011)
New Revision: 4529
Modified:
trunk/cumin/bin/cumin-web
Log:
Change to the way the new parsley code accesses config properties
Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web 2011-02-15 15:38:16 UTC (rev 4528)
+++ trunk/cumin/bin/cumin-web 2011-02-15 15:47:59 UTC (rev 4529)
@@ -25,7 +25,7 @@
cumin.debug = opts.debug
cumin.user = values.user
cumin.update_interval = values.update_interval
- cumin.max_qmf_table_sort = values.web.max_qmf_table_sort
+ cumin.max_qmf_table_sort = values.max_qmf_table_sort
# set default values for form inputs
cumin.set_form_defaults(values.request_memory,
13 years, 3 months
r4528 - in trunk/cumin/python/cumin: . grid messaging
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-15 15:38:16 +0000 (Tue, 15 Feb 2011)
New Revision: 4528
Modified:
trunk/cumin/python/cumin/config.py
trunk/cumin/python/cumin/grid/quota.py
trunk/cumin/python/cumin/messaging/connection.py
trunk/cumin/python/cumin/model.py
trunk/cumin/python/cumin/objectselector.py
trunk/cumin/python/cumin/objectselector.strings
trunk/cumin/python/cumin/objecttask.py
trunk/cumin/python/cumin/qmfadapter.py
Log:
Implemented BZ 673178: Sorting on table columns.
- Added arrow indicating the current sort column and direction
- Added title text to indicate that clicking on a column header will sort the column
- Added sorting to qmf backed table columns
- Used newly added config setting to determine the max sortable records per qmf table
Modified: trunk/cumin/python/cumin/config.py
===================================================================
--- trunk/cumin/python/cumin/config.py 2011-02-15 15:35:09 UTC (rev 4527)
+++ trunk/cumin/python/cumin/config.py 2011-02-15 15:38:16 UTC (rev 4528)
@@ -45,6 +45,9 @@
param = ConfigParameter(web, "update-interval", int)
param.default = 10
+ param = ConfigParameter(web, "max-qmf-table-sort", int)
+ param.default = 1000
+
param = ConfigParameter(web, "host", str)
param.default = "localhost"
Modified: trunk/cumin/python/cumin/grid/quota.py
===================================================================
--- trunk/cumin/python/cumin/grid/quota.py 2011-02-15 15:35:09 UTC (rev 4527)
+++ trunk/cumin/python/cumin/grid/quota.py 2011-02-15 15:38:16 UTC (rev 4528)
@@ -167,9 +167,18 @@
def get_class_list(self, session):
return ["expand"]
+ def render_header_href(self, session):
+ return ""
+
def render_header_content(self, session):
return ""
+ def render_header_title(self, session):
+ return ""
+
+ def render_header_link_class(self, session):
+ return "TableStaticColumnHeader"
+
def render_cell_content(self, session, group):
if not self.group_helper.has_child(session, group):
return ""
Modified: trunk/cumin/python/cumin/messaging/connection.py
===================================================================
--- trunk/cumin/python/cumin/messaging/connection.py 2011-02-15 15:35:09 UTC (rev 4527)
+++ trunk/cumin/python/cumin/messaging/connection.py 2011-02-15 15:38:16 UTC (rev 4528)
@@ -201,6 +201,8 @@
self.close = SessionSelectionClose(app, self)
self.detach = SessionSelectionDetach(app, self)
+ self.enable_csv_export(conn)
+
class SessionSelectionClose(ObjectSelectorTask):
def get_title(self, session):
return "Close"
Modified: trunk/cumin/python/cumin/model.py
===================================================================
--- trunk/cumin/python/cumin/model.py 2011-02-15 15:35:09 UTC (rev 4527)
+++ trunk/cumin/python/cumin/model.py 2011-02-15 15:38:16 UTC (rev 4528)
@@ -1084,9 +1084,9 @@
def completion(status, data):
self.status = status
try:
- self.data = data["Limits"]
- #self.data = {'a':{'CURRENT': 11, 'MAX': 22},
- # 'b':{'CURRENT': 3, 'MAX': 44}}
+ #self.data = data["Limits"]
+ self.data = {'a':{'CURRENT': 11, 'MAX': 22},
+ 'b':{'CURRENT': 3, 'MAX': 44}}
except KeyError:
pass
@@ -1130,8 +1130,8 @@
def completion(status, data):
self.status = status
try:
- self.data = data["Value"]
- #self.data = "MSG, GRID, MGMT, RT, GRID.SUB_1, GRID.SUB_1.SUB_A"
+ #self.data = data["Value"]
+ self.data = "MSG, GRID, MGMT, RT, GRID.SUB_1, GRID.SUB_1.SUB_A"
except KeyError:
pass
@@ -1171,12 +1171,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"
+ 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 update_new(self, cursor):
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2011-02-15 15:35:09 UTC (rev 4527)
+++ trunk/cumin/python/cumin/objectselector.py 2011-02-15 15:38:16 UTC (rev 4528)
@@ -181,6 +181,9 @@
else:
self.field = ObjectSqlField(self.table.adapter, self.attr)
+ def render_header_link_class(self, session):
+ return "TableColumnHeader"
+
class ObjectSelector(Form):
def __init__(self, app, name, cls, object=None):
super(ObjectSelector, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/objectselector.strings
===================================================================
--- trunk/cumin/python/cumin/objectselector.strings 2011-02-15 15:35:09 UTC (rev 4527)
+++ trunk/cumin/python/cumin/objectselector.strings 2011-02-15 15:38:16 UTC (rev 4528)
@@ -185,3 +185,37 @@
}
]]>
</script>
+
+[ObjectTableColumn.css]
+a.TableColumnHeader > span {
+ border:1px solid transparent;
+ padding: 2px 4px;
+ position: relative;
+ left: -5px; /* 4 padding + 1 border */
+}
+a.TableColumnHeader > span:hover {
+ border:1px solid #EAEAEA;
+ background-color: #FFFFFF;
+}
+a.TableColumnHeader > span > span {
+ padding-right: 14px;
+}
+
+/* for right align columns, align with the right */
+th.ralign a.TableColumnHeader > span {
+ left:17px;
+}
+
+/* we moved the th text to the right
+ to align with the column text. we
+ now need to allow space for the sort arrows */
+table.Table th.ralign {
+ overflow: auto;
+}
+
+a.TableColumnHeader span.up {
+ background: url(resource?name=sort-arrow-up.png) right 3px no-repeat;
+}
+a.TableColumnHeader span.down {
+ background: url(resource?name=sort-arrow-down.png) right 4px no-repeat;
+}
Modified: trunk/cumin/python/cumin/objecttask.py
===================================================================
--- trunk/cumin/python/cumin/objecttask.py 2011-02-15 15:35:09 UTC (rev 4527)
+++ trunk/cumin/python/cumin/objecttask.py 2011-02-15 15:38:16 UTC (rev 4528)
@@ -79,10 +79,6 @@
return invoc
- def end(self):
- # called by the invokation when call completes
- pass
-
def invoke(self, session, obj, *args, **kwargs):
if obj:
assert isinstance(obj, RosemaryObject), obj
Modified: trunk/cumin/python/cumin/qmfadapter.py
===================================================================
--- trunk/cumin/python/cumin/qmfadapter.py 2011-02-15 15:35:09 UTC (rev 4527)
+++ trunk/cumin/python/cumin/qmfadapter.py 2011-02-15 15:38:16 UTC (rev 4528)
@@ -12,7 +12,7 @@
self.method = method
self.default = list()
self.columns = list()
- self.max_sortable_records = 1000
+ self.max_sortable_records = app.max_qmf_table_sort
def get_count(self, values):
obj = values['obj']
13 years, 3 months
r4527 - trunk/cumin/python/cumin
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-15 15:35:09 +0000 (Tue, 15 Feb 2011)
New Revision: 4527
Modified:
trunk/cumin/python/cumin/task.py
Log:
Fix exception caused by called .end() on task
Modified: trunk/cumin/python/cumin/task.py
===================================================================
--- trunk/cumin/python/cumin/task.py 2011-02-15 15:33:16 UTC (rev 4526)
+++ trunk/cumin/python/cumin/task.py 2011-02-15 15:35:09 UTC (rev 4527)
@@ -178,7 +178,6 @@
self.end_time = now
self.update_time = now
- self.task.end()
log.info("Ended %s", self.task)
13 years, 3 months
r4526 - trunk/wooly/python/wooly
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-15 15:33:16 +0000 (Tue, 15 Feb 2011)
New Revision: 4526
Modified:
trunk/wooly/python/wooly/table.py
trunk/wooly/python/wooly/table.strings
Log:
Allowed some table header styles to be overridden
Modified: trunk/wooly/python/wooly/table.py
===================================================================
--- trunk/wooly/python/wooly/table.py 2011-02-15 15:26:27 UTC (rev 4525)
+++ trunk/wooly/python/wooly/table.py 2011-02-15 15:33:16 UTC (rev 4526)
@@ -60,7 +60,7 @@
def render_colspan(self, session):
return len(self.get_visible_columns(session))
-
+
def render_rows(self, session):
data = self.get_data(session)
@@ -131,9 +131,26 @@
return branch.marshal()
+ def render_header_title(self, session):
+ sort = self.table.sort.get(session)
+ ascending = self.table.ascending.get(session)
+
+ dir = ascending and "ascending" or "descending"
+ if sort == self.name:
+ dir = ascending and "descending" or "ascending"
+
+ name = self.render_header_content(session)
+ if not name:
+ name = self.name
+
+ return "Click to sort in %s order by %s" % (dir, name)
+
def render_header_content(self, session):
pass
+ def render_header_link_class(self, session):
+ pass
+
def render_cell_content(self, session, record):
pass
@@ -155,14 +172,39 @@
class TableColumnHeader(TableChild):
def render_class(self, session):
- return self.parent.render_class(session)
+ cls = self.parent.render_class(session)
+ align = self.parent.render_text_align(session)
+ if align is "right":
+ return " ".join(("ralign", cls))
+ return cls
+ def render_link_class(self, session):
+ return self.parent.render_header_link_class(session)
+
def render_href(self, session):
return self.parent.render_header_href(session)
def render_content(self, session):
return self.parent.render_header_content(session)
+ def render_sorted_dir(self, session):
+ container = self.table
+ sel = container.sort.get(session)
+ asc = container.ascending.get(session)
+
+ if sel == self.parent.name:
+ if asc:
+ return "up"
+ else:
+ return "down"
+ elif asc:
+ return "unsorted_up"
+ else:
+ return "unsorted_down"
+
+ def render_title(self, session):
+ return self.parent.render_header_title(session)
+
class TableColumnCell(TableChild):
def render_class(self, session, record):
return self.parent.render_class(session)
Modified: trunk/wooly/python/wooly/table.strings
===================================================================
--- trunk/wooly/python/wooly/table.strings 2011-02-15 15:26:27 UTC (rev 4525)
+++ trunk/wooly/python/wooly/table.strings 2011-02-15 15:33:16 UTC (rev 4526)
@@ -53,7 +53,7 @@
}
[TableColumnHeader.html]
-<th class="{class}"><a href="{href}">{content}</a></th>
+<th class="{class}"><a class="{link_class}" title="{title}" href="{href}"><span><span class="{sorted_dir}">{content}</span></span></a></th>
[TableColumnCell.html]
<td class="{class}">{content}</td>
13 years, 3 months
r4525 - in trunk/cumin: bin etc python/cumin
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-15 15:26:27 +0000 (Tue, 15 Feb 2011)
New Revision: 4525
Modified:
trunk/cumin/bin/cumin-web
trunk/cumin/etc/cumin.conf
trunk/cumin/python/cumin/main.py
Log:
Added config entry to set the max number of records in a qmf based tabled before sorting is disabled.
Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web 2011-02-14 19:07:41 UTC (rev 4524)
+++ trunk/cumin/bin/cumin-web 2011-02-15 15:26:27 UTC (rev 4525)
@@ -25,6 +25,7 @@
cumin.debug = opts.debug
cumin.user = values.user
cumin.update_interval = values.update_interval
+ cumin.max_qmf_table_sort = values.web.max_qmf_table_sort
# set default values for form inputs
cumin.set_form_defaults(values.request_memory,
Modified: trunk/cumin/etc/cumin.conf
===================================================================
--- trunk/cumin/etc/cumin.conf 2011-02-14 19:07:41 UTC (rev 4524)
+++ trunk/cumin/etc/cumin.conf 2011-02-15 15:26:27 UTC (rev 4525)
@@ -11,6 +11,7 @@
# port: 45672
# operator-email: [none]
# update-interval: 10
+# max-qmf-table-sort: 1000
[data]
# log-file: $CUMIN_HOME/log/data.log
Modified: trunk/cumin/python/cumin/main.py
===================================================================
--- trunk/cumin/python/cumin/main.py 2011-02-14 19:07:41 UTC (rev 4524)
+++ trunk/cumin/python/cumin/main.py 2011-02-15 15:26:27 UTC (rev 4525)
@@ -53,6 +53,7 @@
self.user = None
self.operator_email = None
self.update_interval = 10
+ self.max_qmf_table_sort = 1000
self.form_defaults = self.CuminFormDefaults()
13 years, 3 months
r4524 - trunk/cumin/python/cumin/inventory
by tmckay@fedoraproject.org
Author: tmckay
Date: 2011-02-14 19:07:41 +0000 (Mon, 14 Feb 2011)
New Revision: 4524
Modified:
trunk/cumin/python/cumin/inventory/system.py
Log:
Change import statement for SlotMap, SlotMapPage
Modified: trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- trunk/cumin/python/cumin/inventory/system.py 2011-02-14 14:27:37 UTC (rev 4523)
+++ trunk/cumin/python/cumin/inventory/system.py 2011-02-14 19:07:41 UTC (rev 4524)
@@ -1,4 +1,4 @@
-from slot import SlotMap, SlotMapPage
+from cumin.grid.slot import SlotMap, SlotMapPage
from cumin.objectselector import ObjectSelector, ObjectLinkColumn
from cumin.objectframe import ObjectFrame
13 years, 3 months
r4523 - trunk/cumin/python/cumin/grid
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-14 14:27:37 +0000 (Mon, 14 Feb 2011)
New Revision: 4523
Modified:
trunk/cumin/python/cumin/grid/negotiator.py
Log:
Don't log no group names returned as an exception when requesting quotas.
Modified: trunk/cumin/python/cumin/grid/negotiator.py
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.py 2011-02-11 20:47:34 UTC (rev 4522)
+++ trunk/cumin/python/cumin/grid/negotiator.py 2011-02-14 14:27:37 UTC (rev 4523)
@@ -87,7 +87,7 @@
try:
groups = self.split_group_names(groups)
except Exception, e:
- log.exception(e)
+ #log.exception(e)
groups = []
if groups:
13 years, 3 months
r4522 - in trunk/cumin/python/cumin: . grid inventory messaging usergrid
by eallen@fedoraproject.org
Author: eallen
Date: 2011-02-11 20:47:34 +0000 (Fri, 11 Feb 2011)
New Revision: 4522
Modified:
trunk/cumin/python/cumin/grid/job.py
trunk/cumin/python/cumin/grid/limit.py
trunk/cumin/python/cumin/grid/negotiator.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/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/objectselector.py
trunk/cumin/python/cumin/objectselector.strings
trunk/cumin/python/cumin/qmfadapter.py
trunk/cumin/python/cumin/usergrid/widgets.py
Log:
Implementing BZ 673180: Add search to all tables. This commit adds the ability to search to the qmf backed tables. (List of Jobs for a submission, and the Limits table)
Also added text to the search field that prompts you to enter a search string. That text disappears when you enter something in the search field.
Also fixed the problem with table checkboxes disappearing after the page auto updates.
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/grid/job.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -222,13 +222,12 @@
self.job_id_column.visible = False
self.add_column(self.job_id_column)
- #self.add_search_filter(cls.GlobalJobId)
-
JobSelectionHold(app, self, "held")
JobSelectionRelease(app, self, "released")
JobSelectionRemove(app, self, "removed")
self.enable_csv_export(submission)
+ self.add_search_filter(self.job_id_col)
def create_table(self, app, name, cls):
return JobSelectorTable(app, name, cls)
Modified: trunk/cumin/python/cumin/grid/limit.py
===================================================================
--- trunk/cumin/python/cumin/grid/limit.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/grid/limit.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -69,8 +69,8 @@
def __init__(self, app, name, cls):
super(LimitTable, self).__init__(app, name, cls)
- col = self.NameColumn(app, "name", cls.Name)
- self.add_column(col)
+ self.name_col = self.NameColumn(app, "name", cls.Name)
+ self.add_column(self.name_col)
col = self.UsageColumn(app, "curr", cls.Usage)
self.add_column(col)
@@ -114,6 +114,7 @@
super(LimitSelector, self).__init__(app, name, cls)
+ self.add_search_filter(self.table.name_col)
self.table.adapter = LimitAdapter(app, cls, collector)
self.enable_csv_export(collector)
Modified: trunk/cumin/python/cumin/grid/negotiator.py
===================================================================
--- trunk/cumin/python/cumin/grid/negotiator.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/grid/negotiator.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -34,6 +34,7 @@
frame = "main.grid.pool.negotiator"
col = ObjectLinkColumn(app, "name", cls.Name, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.Machine)
self.add_attribute_column(cls.System)
@@ -47,8 +48,6 @@
stat = MonitorSelfStatColumn(app, cls.MonitorSelfTime.name, cls.MonitorSelfTime)
self.add_column(stat)
- self.add_search_filter(cls.Name)
-
#self.start = DaemonSelectionStart(app, self, "NEGOTIATOR")
#self.stop = DaemonSelectionStop(app, self, "NEGOTIATOR")
Modified: trunk/cumin/python/cumin/grid/scheduler.py
===================================================================
--- trunk/cumin/python/cumin/grid/scheduler.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/grid/scheduler.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -85,6 +85,7 @@
frame = "main.grid.pool.scheduler"
col = ObjectLinkColumn(app, "name", cls.Name, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.NumUsers)
self.add_attribute_column(cls.TotalIdleJobs)
@@ -100,8 +101,6 @@
stat = MonitorSelfStatColumn(app, cls.MonitorSelfTime.name, cls.MonitorSelfTime)
self.add_column(stat)
- self.add_search_filter(cls.Name)
-
#self.start = DaemonSelectionStart(app, self, "SCHEDD")
#self.stop = DaemonSelectionStop(app, self, "SCHEDD")
Modified: trunk/cumin/python/cumin/grid/slot.py
===================================================================
--- trunk/cumin/python/cumin/grid/slot.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/grid/slot.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -24,11 +24,11 @@
self.pool = pool
self.add_filter(self.pool, cls.Pool, cls.Pool)
- self.add_search_filter(cls.Name)
frame = "main.grid.pool.slot"
col = ObjectLinkColumn(app, "name", cls.Name, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.Activity)
self.add_attribute_column(cls.State)
Modified: trunk/cumin/python/cumin/grid/submission.py
===================================================================
--- trunk/cumin/python/cumin/grid/submission.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/grid/submission.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -75,8 +75,6 @@
self.add_attribute_column(cls.Completed)
self.add_attribute_column(cls.Held)
- self.add_search_filter(cls.Name)
-
class PoolSubmissionSelector(SubmissionSelector):
def __init__(self, app, name, pool):
super(PoolSubmissionSelector, self).__init__(app, name)
@@ -89,6 +87,7 @@
frame = "main.grid.pool.submission"
col = ObjectLinkColumn(app, "name", self.cls.Name, self.cls._id, frame)
self.insert_column(1, col)
+ self.add_search_filter(col)
attr = self.cls.Owner
col = ObjectTableColumn(app, attr.name, attr)
Modified: trunk/cumin/python/cumin/grid/submitter.py
===================================================================
--- trunk/cumin/python/cumin/grid/submitter.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/grid/submitter.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -43,6 +43,7 @@
frame = "main.grid.pool.scheduler.submitter"
col = ObjectLinkColumn(app, "name", cls.Name, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.Machine)
self.add_attribute_column(cls.ScheddName)
@@ -50,8 +51,6 @@
self.add_attribute_column(cls.RunningJobs)
self.add_attribute_column(cls.HeldJobs)
- self.add_search_filter(cls.Name)
-
self.enable_csv_export(scheduler)
class SubmitterGeneralStatSet(StatSet):
Modified: trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- trunk/cumin/python/cumin/inventory/system.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/inventory/system.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -1,18 +1,15 @@
-from mint import *
-from wooly import *
-from wooly.widgets import *
-from cumin.objectframe import *
-from cumin.objectselector import *
-from cumin.stat import *
-from cumin.widgets import *
-from cumin.parameters import *
-from cumin.formats import *
-from cumin.util import *
-from cumin.grid.slot import SlotFrame, SlotMap, SlotMapPage
+from slot import SlotMap, SlotMapPage
-from wooly import Session
-import main
+from cumin.objectselector import ObjectSelector, ObjectLinkColumn
+from cumin.objectframe import ObjectFrame
+from cumin.stat import StatSet, StatFlashChart
+from cumin.formats import fmt_bytes
+from cumin.model import CuminStatistic
+from cumin.parameters import RosemaryObjectParameter
+from wooly import Session, Widget
+from wooly.util import StringCatalog
+
strings = StringCatalog(__file__)
class SystemSelector(ObjectSelector):
@@ -24,14 +21,13 @@
frame = "main.inventory.system"
col = ObjectLinkColumn(app, "name", cls.nodeName, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.osName)
self.add_attribute_column(cls.machine)
self.add_attribute_column(cls.memFree)
self.add_attribute_column(cls.loadAverage1Min)
- self.add_search_filter(cls.nodeName)
-
self.enable_csv_export()
class SystemFrame(ObjectFrame):
@@ -150,86 +146,6 @@
def render_slot_chart_height(self, session):
return 400
-class OldSystemView(CuminView):
- def __init__(self, app, name, system):
- super(OldSystemView, self).__init__(app, name, system)
-
- self.tabs = TabbedModeSet(app, "tabs")
- self.add_child(self.tabs)
-
- self.tabs.add_tab(SystemStats(app, "stats", system))
- self.tabs.add_tab(SystemServices(app, "services", system))
- self.tabs.add_tab(CuminDetails(app, "details", system))
-
-class SystemServices(ItemSet):
- def __init__(self, app, name, system):
- super(SystemServices, self).__init__(app, name)
-
- self.system = system
-
- def render_title(self, session):
- return "Services"
-
- def do_get_items(self, session):
- system = self.system.get(session)
-
- daemons = list()
- daemon_types = [Scheduler, Collector, Negotiator]
- sql = "system = '%s'" % system.nodeName
-
- for daemon in daemon_types:
- system_daemons = daemon.select(sql)
- for devil in system_daemons:
- try:
- daemons.append(devil)
- except Exception, e:
- pass
-
- # using a loop instead of an sql select with an outer join
- brokers = Broker.select()
-
- for broker in brokers:
- if broker.system.nodeName == system.nodeName:
- daemons.append(broker)
-
- return daemons
-
- def render_item_content(self, session, item):
- if isinstance(item, Broker):
- broker = Identifiable(item.id)
- href = self.page.main.messaging.broker.get_href(session, broker)
- return fmt_link(href, item.port) # XXX item.port is too lame
- else:
- pool = Pool(item.Pool)
- self.page.main.grid.pool.object.set(session, pool)
- #self.page.main.show_grid_tab(session)
- daemon = Identifiable(item.id)
- if isinstance(item, Collector):
- self.page.main.grid.pool.view.collectors.show(session)
- href = self.page.main.grid.pool.collector.get_href \
- (session, daemon)
- elif isinstance(item, Scheduler):
- self.page.main.grid.pool.view.schedulers.show(session)
- href = self.page.main.grid.pool.scheduler.get_href \
- (session, daemon)
- elif isinstance(item, Negotiator):
- self.page.main.grid.pool.view.negotiators.show(session)
- href = self.page.main.grid.pool.negotiator.get_href \
- (session, daemon)
- return fmt_link(href, item.Name)
-
- def render_item_type(self, session, item):
- if isinstance(item, Collector):
- return "Collector"
- elif isinstance(item, Scheduler):
- return "Scheduler"
- elif isinstance(item, Negotiator):
- return "Negotiator"
- elif isinstance(item, Broker):
- return "Broker"
- else:
- return "Daemon"
-
class SystemSlotMapPage(SlotMapPage):
def __init__(self, app, name):
self.cls = app.model.com_redhat_sesame.Sysimage
Modified: trunk/cumin/python/cumin/messaging/binding.py
===================================================================
--- trunk/cumin/python/cumin/messaging/binding.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/messaging/binding.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -141,6 +141,7 @@
col = ObjectLinkColumn \
(app, "binding", binding.bindingKey, binding._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
frame = "main.messaging.broker.exchange"
self.exchange_column = self.Exchange \
@@ -157,8 +158,6 @@
self.remove = BindingSelectionRemove(app, self)
- self.add_search_filter(binding.bindingKey)
-
self.enable_csv_export()
class Exchange(ObjectLinkColumn):
Modified: trunk/cumin/python/cumin/messaging/brokerlink.py
===================================================================
--- trunk/cumin/python/cumin/messaging/brokerlink.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/messaging/brokerlink.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -67,14 +67,13 @@
frame = "main.messaging.broker.link"
col = ObjectLinkColumn(app, "name", cls.host, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.port)
self.add_attribute_column(cls.state)
self.add_attribute_column(cls.transport)
self.add_attribute_column(cls.durable)
- self.add_search_filter(cls.host)
-
self.remove = BrokerLinkSelectionRemove(app, self)
self.enable_csv_export(vhost)
@@ -96,14 +95,14 @@
self.add_reference_filter(self.link, cls.linkRef)
- self.add_attribute_column(cls.src)
+ col = self.add_attribute_column(cls.src)
+ self.add_search_filter(col)
+
self.add_attribute_column(cls.dest)
self.add_attribute_column(cls.key)
self.add_attribute_column(cls.tag)
self.add_attribute_column(cls.excludes)
- self.add_search_filter(cls.src)
-
self.remove = RouteSelectionRemove(app, self)
class RouteSelectionRemove(ObjectSelectorTask):
Modified: trunk/cumin/python/cumin/messaging/connection.py
===================================================================
--- trunk/cumin/python/cumin/messaging/connection.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/messaging/connection.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -63,6 +63,7 @@
frame = "main.messaging.broker.connection"
col = ObjectLinkColumn(app, "address", cls.address, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
col = ConnectionProcessColumn \
(app, "process", cls.remoteProcessName, cls.remotePid)
@@ -74,8 +75,6 @@
self.add_attribute_column(cls.bytesFromClient)
self.add_attribute_column(cls.bytesToClient)
- self.add_search_filter(cls.address)
-
self.close = ConnectionSelectionClose(app, self)
self.enable_csv_export(vhost)
@@ -192,14 +191,13 @@
frame = "main.messaging.broker.connection.session"
col = ObjectLinkColumn(app, "name", cls.name, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.attached)
self.add_attribute_column(cls.detachedLifespan)
self.add_attribute_column(cls.framesOutstanding)
self.add_attribute_column(cls.clientCredit)
- self.add_search_filter(cls.name)
-
self.close = SessionSelectionClose(app, self)
self.detach = SessionSelectionDetach(app, self)
Modified: trunk/cumin/python/cumin/messaging/exchange.py
===================================================================
--- trunk/cumin/python/cumin/messaging/exchange.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/messaging/exchange.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -72,6 +72,7 @@
frame = "main.messaging.broker.exchange"
col = self.ExchangeNameColumn(app, "name", cls.name, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.producerCount)
self.add_attribute_column(cls.bindingCount)
@@ -79,7 +80,6 @@
self.add_attribute_column(cls.byteRoutes)
self.add_reference_filter(vhost, cls.vhostRef)
- self.add_search_filter(cls.name)
self.remove = ExchangeSelectionRemove(app, self)
Modified: trunk/cumin/python/cumin/messaging/queue.py
===================================================================
--- trunk/cumin/python/cumin/messaging/queue.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/messaging/queue.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -72,6 +72,7 @@
frame = "main.messaging.broker.queue"
col = ObjectLinkColumn(app, "name", cls.name, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.consumerCount)
self.add_attribute_column(cls.bindingCount)
@@ -79,7 +80,6 @@
self.add_attribute_column(cls.byteDepth)
self.add_reference_filter(vhost, cls.vhostRef)
- self.add_search_filter(cls.name)
self.remove = QueueSelectionRemove(app, self)
self.purge = QueueSelectionPurge(app, self)
Modified: trunk/cumin/python/cumin/messaging/subscription.py
===================================================================
--- trunk/cumin/python/cumin/messaging/subscription.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/messaging/subscription.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -16,13 +16,12 @@
frame = "main.messaging.broker.queue.subscription"
col = ObjectLinkColumn(app, "name", cls.name, cls._id, frame)
self.add_column(col)
+ self.add_search_filter(col)
self.add_attribute_column(cls.creditMode)
self.add_attribute_column(cls.arguments)
self.add_attribute_column(cls.delivered)
- self.add_search_filter(cls.name)
-
self.enable_csv_export(queue)
class SubscriptionFrame(ObjectFrame):
Modified: trunk/cumin/python/cumin/objectselector.py
===================================================================
--- trunk/cumin/python/cumin/objectselector.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/objectselector.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -35,7 +35,7 @@
# (RosemaryAttribute this, RosemaryAttribute that, Attribute object)
self.filter_specs = list()
- # ((RosemaryAttribute this, Attribute value, SqlLikeFilter.BEGINS)
+ # ((RosemaryAttribute this, Attribute value, SqlLikeFilter.CONTAINS)
self.like_specs = list()
def init(self):
@@ -47,8 +47,8 @@
for this, that, fobj in self.filter_specs:
self.adapter.add_value_filter(this)
- for this, vattr, type in self.like_specs:
- self.adapter.add_like_filter(this)
+ for column, vattr, type in self.like_specs:
+ self.adapter.add_like_filter(column.attr)
if self.sort.default is None:
for col in self.columns:
@@ -83,11 +83,11 @@
self.add_filter(attribute, this, that)
- def add_like_filter(self, attribute, this, type=SqlLikeFilter.CONTAINS):
+ def add_like_filter(self, attribute, column, type=SqlLikeFilter.CONTAINS):
assert isinstance(attribute, Attribute), attribute
- assert isinstance(this, RosemaryAttribute), this
+ assert isinstance(column, DataTableColumn), column
- self.like_specs.append((this, attribute, type))
+ self.like_specs.append((column, attribute, type))
def get_data_values(self, session):
values = dict()
@@ -105,7 +105,7 @@
pre = type == SqlLikeFilter.CONTAINS and "%%" or ""
else:
post = ""
- values[this.name] = "%s%s%s" % (pre, value, post)
+ values[this.attr.name] = "%s%s%s" % (pre, value, post)
return values
@@ -232,10 +232,15 @@
def add_search_filter(self, this):
search = StringInput(self.app, "search")
search.param.default = ""
+ search.title = "Enter search term"
self.table.add_like_filter(search.param, this)
self.filters.add_child(search)
+ def render_search_id(self, session):
+ if len(self.filters.children):
+ return self.filters.children[0].render_id(session)
+
def add_filter(self, attribute, this, that=None):
self.table.add_filter(attribute, this, that)
@@ -243,7 +248,7 @@
self.table.add_column(col)
def add_attribute_column(self, attr):
- self.table.add_attribute_column(attr)
+ return self.table.add_attribute_column(attr)
def add_reference_filter(self, attribute, ref):
self.table.add_reference_filter(attribute, ref)
@@ -258,6 +263,9 @@
if self.export:
return self.export.render(session)
+ def render_script(self, session):
+ return ""
+
def get_data_values(self, session):
return self.table.get_data_values(session)
@@ -539,6 +547,10 @@
self.details = QmfDetails(app, "details", self.status_msg)
self.add_child(self.details)
+ self.script = self.ObjectQmfSelectorScript(app, "script")
+ self.script.comments_enabled = False
+ self.add_child(self.script)
+
self.error_tmpl = WidgetTemplate(self, "error_html")
self.loading_tmpl = WidgetTemplate(self, "deferred_html")
@@ -586,20 +598,35 @@
def render_error_msg(self, session, msg):
return msg
-class ObjectQmfTable(ObjectTable):
+ def render_script(self, session):
+ return self.script.render(session)
+
+ class ObjectQmfSelectorScript(Widget):
+ def render_table_id(self, session):
+ return self.parent.table.render_id(session)
+
+ def render_selector_id(self, session):
+ return self.parent.render_id(session)
+
+class QmfValues(Widget):
def get_data_values(self, session):
- values = super(ObjectQmfTable, self).get_data_values(session)
+ values = super(QmfValues, self).get_data_values(session)
# session is needed to retrieve the qmf data
values['session'] = session
return values
-class ObjectQmSelectorfTable(ObjectSelectorTable):
- def get_data_values(self, session):
- values = super(ObjectQmSelectorfTable, self).get_data_values(session)
+ def get_data_options(self, session):
+ options = super(QmfValues, self).get_data_options(session)
- # session is needed to retrieve the qmf data
- values['session'] = session
+ # store the search filter in the options
+ setattr(options, "like_specs", self.like_specs)
- return values
+ return options
+
+class ObjectQmfTable(QmfValues, ObjectTable):
+ pass
+
+class ObjectQmSelectorfTable(QmfValues, ObjectSelectorTable):
+ pass
\ No newline at end of file
Modified: trunk/cumin/python/cumin/objectselector.strings
===================================================================
--- trunk/cumin/python/cumin/objectselector.strings 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/objectselector.strings 2011-02-11 20:47:34 UTC (rev 4522)
@@ -5,6 +5,11 @@
padding: 0;
}
+div.ObjectSelector label.overTxtLabel {
+ font-size: 12px;
+ color: #999;
+}
+
div.ObjectSelectorFilters {
float: right;
padding-bottom: 0.25em;
@@ -53,7 +58,10 @@
<div>{hidden_inputs}</div>
</form>
<script type="text/javascript">
- cumin.restoreTableCheckboxes();
+<![CDATA[
+ $(document.forms[0]).getElements('[type=text]').each(function(el){ new OverText(el); });
+ {script}
+]]>
</script>
</div>
@@ -66,6 +74,9 @@
{footer}
<tbody>{rows}</tbody>
</table>
+ <script type="text/javascript">
+ cumin.restoreTableCheckboxes();
+ </script>
[ObjectSelectorControl.html]
<div class="{class}">
@@ -123,6 +134,21 @@
</div>
</div>
+[ObjectQmfSelectorScript.html]
+(function() {
+ // don't update the entire form anymore
+ // just update the table
+ var updateUrl = wooly.branchIntervalUpdate();
+
+ for (var i=0; i<updateUrl.widget.length; i++) {
+ if (updateUrl.widget[i] == "{selector_id}") {
+ updateUrl.widget[i] = "{table_id}";
+ wooly.restartIntervalUpdate(updateUrl.marshal());
+ break;
+ }
+ }
+}())
+
[QmfDetails.css]
div.QmfDetails span.DetailsLink {
font-size: 80%;
@@ -147,11 +173,11 @@
var details = $("{id}_details");
var show_hide = $("{id}_link");
if (details.style.display == "block") {
- show_hide.innerHTML = "show";
+ show_hide.set('text', "show");
details.style.display = "none";
delete branch["{details_path}"];
} else {
- show_hide.innerHTML = "hide";
+ show_hide.set('text', "hide");
details.style.display = "block";
branch["{details_path}"] = "1";
}
Modified: trunk/cumin/python/cumin/qmfadapter.py
===================================================================
--- trunk/cumin/python/cumin/qmfadapter.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/qmfadapter.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -1,7 +1,9 @@
from operator import itemgetter
from cumin.model import QmfCall
from wooly.datatable import DataAdapter, DataAdapterField
+import logging
+log = logging.getLogger("cumin.qmfadapter")
class QmfAdapter(DataAdapter):
def __init__(self, app, method):
super(QmfAdapter, self).__init__()
@@ -31,6 +33,7 @@
else:
rows = []
+ rows = self.filter_rows(rows, values, options)
rows = self.sort_rows(rows, options)
rows = self.limit_rows(rows, options)
@@ -81,6 +84,22 @@
field_data.append(val)
return field_data
+ def filter_rows(self, rows, values, options):
+ filtered = list(rows)
+ try:
+ session = values["session"]
+ for column, vattr, type in options.like_specs:
+ compare = vattr.get(session)
+ index = column.field.index
+ #TODO: handle more than the CONTAINS filter type
+ filtered = [x for x in rows
+ if compare in x[index]]
+ rows = filtered
+ except Exception, e:
+ log.exception(e)
+
+ return rows
+
def sort_rows(self, rows, options):
if len(rows) > self.max_sortable_records:
return rows
@@ -110,7 +129,9 @@
self.fields_by_attr = dict()
def add_like_filter(self, attr):
- #TODO: add sql LIKE filtering to QMF results
+ # qmf adapters don't need to add the like filter
+ # since the filtering is done after the records
+ # are returned in filter_rows
pass
class QmfField(DataAdapterField):
Modified: trunk/cumin/python/cumin/usergrid/widgets.py
===================================================================
--- trunk/cumin/python/cumin/usergrid/widgets.py 2011-02-11 20:25:48 UTC (rev 4521)
+++ trunk/cumin/python/cumin/usergrid/widgets.py 2011-02-11 20:47:34 UTC (rev 4522)
@@ -114,6 +114,7 @@
frame = "main.submissions.submission"
col = ObjectLinkColumn(app, "name", self.cls.Name, self.cls._id, frame)
self.insert_column(1, col)
+ self.add_search_filter(col)
link = TaskLink(app, "job_submit", app.grid.job_submit)
self.links.add_child(link)
13 years, 3 months