Author: eallen
Date: 2008-10-07 18:20:45 -0400 (Tue, 07 Oct 2008)
New Revision: 2603
Modified:
mgmt/trunk/cumin/python/cumin/limits.py
mgmt/trunk/cumin/python/cumin/limits.strings
Log:
Used AjaxField to update the Concurrency Limit count after page loads.
Modified: mgmt/trunk/cumin/python/cumin/limits.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.py 2008-10-07 22:20:19 UTC (rev 2602)
+++ mgmt/trunk/cumin/python/cumin/limits.py 2008-10-07 22:20:45 UTC (rev 2603)
@@ -61,7 +61,6 @@
wait(predicate, timeout=5)
return self.lim
-
class LimitsSet(ItemTable, LimitActions):
def __init__(self, app, name):
super(LimitsSet, self).__init__(app, name)
@@ -81,6 +80,9 @@
self.limits = self.Limits(self, "limits")
self.add_attribute(self.limits)
+ self.limit_count = self.LimitCount(app, "limit_count")
+ self.add_child(self.limit_count)
+
def do_get_items(self, session, *args):
limits = self.limits.get(session)
keys = limits.keys()
@@ -88,8 +90,8 @@
return [{"name":x, "curr":limits[x]["CURRENT"],
"max":limits[x]["MAX"]} for x in keys]
def render_title(self, session):
- return "Concurrency Limits %s" % fmt_count(self.limit_count(session))
-
+ return self.limit_count.get_title(session, "Concurrency Limits")
+
def limit_count(self, session):
limits = self.limits.get(session)
if not limits:
@@ -97,6 +99,16 @@
self.limits.set(session, limits)
return limits and len(limits) or 0
+ class LimitCount(AjaxField):
+ def get_url(self, session):
+ negotiator = self.parent.get_negotiator(session)
+ if negotiator:
+ return "data.xml?class=negotiator;id=%i;method=GetLimitCount" %
negotiator.id
+
+ def get_title(self, session, title):
+ return "%s <span id=\"%s\">%s</span>" % \
+ (title, self.name, self.render_script(session))
+
class NameColumn(ItemTableColumn):
def render_title(self, session, data):
return "Name"
Modified: mgmt/trunk/cumin/python/cumin/limits.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.strings 2008-10-07 22:20:19 UTC (rev 2602)
+++ mgmt/trunk/cumin/python/cumin/limits.strings 2008-10-07 22:20:45 UTC (rev 2603)
@@ -10,7 +10,17 @@
</thead>
<tbody>{items}</tbody>
</table>
+{limit_count}
+[LimitCount.javascript]
+function got_limit_count(obj, id) {
+ var elem = document.getElementById(id);
+ if (elem) {
+ var str = "<span class='count'>(" + obj.count.value +
")</span>";
+ elem.innerHTML = str;
+ }
+}
+
[LimitEdit.css]
form.limitform {
/* padding: 1em; */