rhmessaging commits: r2612 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-10-09 16:31:20 -0400 (Thu, 09 Oct 2008)
New Revision: 2612
Modified:
mgmt/trunk/cumin/python/cumin/formats.py
mgmt/trunk/cumin/python/cumin/job.py
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/widgets.py
mgmt/trunk/cumin/python/cumin/widgets.strings
Log:
Some enhancements to our logic for shortening long names.
- Adds pre and post args (optional) to fmt_shorten
- Moves fmt_shorten out of get_object_title and instead to call sites
I also shortened some column titles so they wouldn't wrap.
Modified: mgmt/trunk/cumin/python/cumin/formats.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/formats.py 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/formats.py 2008-10-09 20:31:20 UTC (rev 2612)
@@ -109,12 +109,15 @@
def fmt_none_brief():
return "<span class=\"none\">–</span>"
-def fmt_shorten(string):
- if len(string) > 20:
- return string[:13] + "..." + string[-6:]
- else:
- return string
+def fmt_shorten(string, pre=16, post=0):
+ if len(string) > pre + post:
+ if post:
+ string = string[:pre] + "…" + string[-post:]
+ else:
+ string = string[:pre] + "…"
+ return string
+
def fmt_link(href, content, class_="", id="", link_title=""):
return "<a %s href=\"%s\"%s%s>%s</a>" % \
(id and "id=\"%s\"" % id or "", href, class_ and " class=\"%s\" " % class_ or " ",
Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/job.py 2008-10-09 20:31:20 UTC (rev 2612)
@@ -97,7 +97,7 @@
class ConcurrencyLimitsColumn(SqlTableColumn):
def render_title(self, session, data):
- return "Concurrency Limits"
+ return "Conc. Limits"
class CustomGroupColumn(SqlTableColumn):
def render_title(self, session, data):
@@ -108,11 +108,12 @@
if job_group:
branch = session.branch()
self.frame.show_job_group(branch, job_group).show_view(branch)
- return fmt_olink(branch, job_group, name=data[self.name])
+ name = fmt_shorten(data[self.name])
+ return fmt_olink(branch, job_group, name=name)
class CustomIdColumn(SqlTableColumn):
def render_title(self, session, data):
- return "Custom Id"
+ return "ID"
def render_content(self, session, data):
job = Identifiable(data["id"])
@@ -163,7 +164,8 @@
if data["submitter"]:
branch = session.branch()
self.frame.show_submitter(branch, submitter).show_view(branch)
- return fmt_olink(branch, submitter, name=data["submitter"])
+ name = fmt_shorten(data["submitter"])
+ return fmt_olink(branch, submitter, name=name)
else:
return data["scheduler"]
@@ -176,7 +178,8 @@
if data["scheduler"]:
branch = session.branch()
self.frame.show_scheduler(branch, scheduler).show_view(branch)
- return fmt_olink(branch, scheduler, name=data["scheduler"])
+ name = fmt_shorten(data["scheduler"])
+ return fmt_olink(branch, scheduler, name=name)
else:
return data["scheduler"]
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-10-09 20:31:20 UTC (rev 2612)
@@ -443,7 +443,7 @@
def get_object_title(self, session, object):
title = self.get_title(session)
name = self.get_object_name(object)
- return "%s '%s'" % (title, fmt_shorten(name))
+ return "%s '%s'" % (title, name)
def get_object_name(self, object):
return object.name
@@ -1620,7 +1620,7 @@
def get_object_title(self, session, limit):
title = self.get_title(session)
name = limit.id
- return "%s '%s'" % (title, fmt_shorten(name))
+ return "%s '%s'" % (title, name)
class SetLimit(CuminAction):
def show(self, session, job):
@@ -1673,7 +1673,7 @@
def get_object_title(self, session, group):
title = self.get_title(session)
name = group.get_id()
- return "%s '%s'" % (title, fmt_shorten(name))
+ return "%s '%s'" % (title, name)
def get_title(self, session):
return "Job Group"
@@ -2415,4 +2415,4 @@
writer.write("<data>")
writer.write(data)
writer.write("</data>")
-
\ No newline at end of file
+
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2008-10-09 20:31:20 UTC (rev 2612)
@@ -116,7 +116,7 @@
cls = self.app.model.get_class_by_object(obj)
- return cls.get_object_title(session, obj)
+ return fmt_shorten(cls.get_object_title(session, obj), 16, 4)
class CuminView(Widget):
def __init__(self, app, name):
Modified: mgmt/trunk/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.strings 2008-10-09 19:50:25 UTC (rev 2611)
+++ mgmt/trunk/cumin/python/cumin/widgets.strings 2008-10-09 20:31:20 UTC (rev 2612)
@@ -771,7 +771,7 @@
[CuminSummary.css]
div.CuminSummary {
- width: 32em;
+ width: 36em;
margin: 0 0 2em 0;
min-height: 6em;
}
16 years, 2 months
rhmessaging commits: r2611 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-10-09 15:50:25 -0400 (Thu, 09 Oct 2008)
New Revision: 2611
Modified:
mgmt/trunk/cumin/python/cumin/job.py
Log:
Fix up some render args
Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py 2008-10-09 17:11:04 UTC (rev 2610)
+++ mgmt/trunk/cumin/python/cumin/job.py 2008-10-09 19:50:25 UTC (rev 2611)
@@ -962,7 +962,7 @@
class JobsAndGroupsTab(Widget):
def __init__(self, app, name):
super(JobsAndGroupsTab, self).__init__(app, name)
-
+
self.is_group = GroupSwitch(app, "group")
self.add_child(self.is_group)
@@ -975,7 +975,7 @@
def get_args(self, session):
return self.frame.get_args(session)
- def render_title(self, session, job):
+ def render_title(self, session, *args):
return "Jobs %s" % fmt_count(Job.select().count())#self.job_tab.get_item_count(session, job))
def show_status_switch(self, session):
@@ -993,12 +993,12 @@
if is_group == "j":
return self.job_tab.phase.render(session)
- def render_jobs(self, session, args):
+ def render_jobs(self, session, *args):
is_group = self.is_group.get(session)
if is_group == "j":
return self.job_tab.render(session)
- def render_job_groups(self, session, args):
+ def render_job_groups(self, session, *args):
is_group = self.is_group.get(session)
if is_group == "g":
return self.job_group_tab.render(session)
16 years, 2 months
rhmessaging commits: r2610 - in mgmt/trunk: cumin-test-0/etc and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-10-09 13:11:04 -0400 (Thu, 09 Oct 2008)
New Revision: 2610
Modified:
mgmt/trunk/cumin-test-0/etc/cumin.conf
mgmt/trunk/cumin/python/cumin/__init__.py
Log:
To save us all some typing, automatically log in the guest user in the devel environment
Modified: mgmt/trunk/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/__init__.py 2008-10-09 14:46:28 UTC (rev 2609)
+++ mgmt/trunk/cumin/python/cumin/__init__.py 2008-10-09 17:11:04 UTC (rev 2610)
@@ -16,7 +16,7 @@
from page import MainPage
from stat import StatChartPage
from action import ActionPage
-from user import LoginPage
+from user import LoginPage, UserSession
from wooly import Session
@@ -157,6 +157,18 @@
return True
+ if self.app.config.user:
+ user = Subject.getByName(self.app.config.user)
+
+ assert user
+
+ usess = UserSession(self.app, user)
+ session.set_cookie("session", usess.id)
+
+ page.set_redirect_url(session, session.marshal())
+
+ return False
+
lpage = self.app.login_page
lsess = Session(lpage)
lpage.origin.set(lsess, session.marshal())
@@ -197,6 +209,8 @@
param = ConfigParameter(self, "debug", bool)
param.default = False
+ param = ConfigParameter(self, "user", str)
+
def init(self):
super(CuminConfig, self).init()
Modified: mgmt/trunk/cumin-test-0/etc/cumin.conf
===================================================================
--- mgmt/trunk/cumin-test-0/etc/cumin.conf 2008-10-09 14:46:28 UTC (rev 2609)
+++ mgmt/trunk/cumin-test-0/etc/cumin.conf 2008-10-09 17:11:04 UTC (rev 2610)
@@ -1,2 +1,3 @@
[main]
debug: True
+user: guest
16 years, 2 months
rhmessaging commits: r2609 - store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2008-10-09 10:46:28 -0400 (Thu, 09 Oct 2008)
New Revision: 2609
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java
Log:
Updated tool to allow inplace upgrades. This works by upgrading to a temporary store in the same directory as the requested upgrade directory then replacing the specified input with the newly upgraded store.
Modified: store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java 2008-10-08 21:10:44 UTC (rev 2608)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java 2008-10-09 14:46:28 UTC (rev 2609)
@@ -101,6 +101,7 @@
private static final String OPTION_QUIET = "quiet";
private static final String OPTION_FORCE_SHORT = "f";
private static final String OPTION_FORCE = "force";
+ private boolean _inplace = false;
public BDBStoreUpgrade(String fromDir, String toDir, String backupDir, boolean interactive, boolean force)
{
@@ -119,10 +120,19 @@
throw new IllegalArgumentException("Specified directory '" + fromDir + "' does not contain a valid BDBMessageStore.");
}
- _toDir = new File(toDir);
+ if (toDir == null)
+ {
+ _inplace = true;
+ _toDir = new File(fromDir+"-Inplace");
+ }
+ else
+ {
+ _toDir = new File(toDir);
+ }
+
if (_toDir.exists())
{
- if (interactive)
+ if (_interactive)
{
System.out.println("Upgrade destination: '" + toDir + "'");
@@ -140,7 +150,7 @@
}
else
{
- if (force)
+ if (_force)
{
if (!FileUtils.delete(_toDir, true))
{
@@ -239,7 +249,8 @@
*/
public void upgradeFromVersion(int version) throws Exception
{
- upgradeFromVersion(version, _fromDir, _toDir, _backupDir, _force);
+ upgradeFromVersion(version, _fromDir, _toDir, _backupDir, _force,
+ _inplace);
}
/**
@@ -248,15 +259,22 @@
* @param version the version of the current store
* @param fromDir the directory with the old Store
* @param toDir the directrory to hold the newly Upgraded Store
+ * @param backupDir the directrory to backup to if required
+ * @param force suppress all questions
+ * @param inplace replace the from dir with the upgraded result in toDir
*
- * @throws Exception due to Virtualhost/MessageStore.close() being rather poor at exception handling
+ * @throws Exception due to Virtualhost/MessageStore.close() being
+ * rather poor at exception handling
* @throws DatabaseException if there is a problem with the store formats
- * @throws AMQException if there is an issue creating Qpid data structures
+ * @throws AMQException if there is an issue creating Qpid data structures
*/
- public void upgradeFromVersion(int version, File fromDir, File toDir, File backupDir, boolean force) throws Exception
+ public void upgradeFromVersion(int version, File fromDir, File toDir,
+ File backupDir, boolean force,
+ boolean inplace) throws Exception
{
_logger.info("Located store to upgrade at '" + fromDir + "'");
+ // Verify user has created a backup, giving option to perform backup
if (_interactive)
{
if (!userInteract("Have you performed a DB backup of this store."))
@@ -336,6 +354,25 @@
//Shutdown the AR that the Vhosts will have created.
ApplicationRegistry.remove(1);
+
+ // if we are running inplace then swap fromDir and toDir
+ if (inplace)
+ {
+ // Remove original copy
+ if (FileUtils.delete(fromDir, true))
+ {
+ // Rename upgraded store
+ toDir.renameTo(fromDir);
+ }
+ else
+ {
+ throw new RuntimeException("Unable to upgrade inplace as " +
+ "unable to delete source '"
+ +fromDir+"', Store upgrade " +
+ "successfully performed to :"
+ +toDir);
+ }
+ }
}
}
@@ -636,8 +673,14 @@
for (File store : stores)
{
- // Check to see if we are upgrading a store specified in fromDir or if the directories are nested.
- if (stores.length > 0 && stores[0].toString().length() == fromDir.length())
+
+ // if toDir is null then we are upgrading inplace so we don't need
+ // to provide an upgraded toDir when upgrading multiple stores.
+ if (toDir == null ||
+ // Check to see if we are upgrading a store specified in
+ // fromDir or if the directories are nested.
+ (stores.length > 0
+ && stores[0].toString().length() == fromDir.length()))
{
upgrade(store, toDir, backupDir, interactive, force);
}
@@ -657,7 +700,7 @@
.create(OPTION_INPUT_SHORT);
Option output =
- OptionBuilder.isRequired().hasArg().withDescription("Location (Path) for the upgraded-db to be written.").withLongOpt(OPTION_OUTPUT)
+ OptionBuilder.hasArg().withDescription("Location (Path) for the upgraded-db to be written.").withLongOpt(OPTION_OUTPUT)
.create(OPTION_OUTPUT_SHORT);
Option quiet = new Option(OPTION_QUIET_SHORT, OPTION_QUIET, false, "Disable interactive options.");
@@ -696,7 +739,7 @@
}
catch (Exception e)
{
- _logger.error("Upgrade Failed: " + e.getMessage());
+ _logger.error("Upgrade Failed: " + e.getMessage());
}
}
16 years, 2 months
rhmessaging commits: r2608 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2008-10-08 17:10:44 -0400 (Wed, 08 Oct 2008)
New Revision: 2608
Modified:
mgmt/trunk/cumin/python/cumin/client.py
Log:
Display Session.expire_time as a dateTime object and not a long
Modified: mgmt/trunk/cumin/python/cumin/client.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/client.py 2008-10-08 18:30:55 UTC (rev 2607)
+++ mgmt/trunk/cumin/python/cumin/client.py 2008-10-08 21:10:44 UTC (rev 2608)
@@ -358,7 +358,7 @@
return "Expires"
def render_value(self, session, value):
- return fmt_datetime(datetime.fromtimestamp(value / 1000000000))
+ return fmt_datetime(value)
class StatusColumn(SqlTableColumn):
def render_title(self, session, data):
16 years, 2 months
rhmessaging commits: r2607 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2008-10-08 14:30:55 -0400 (Wed, 08 Oct 2008)
New Revision: 2607
Modified:
mgmt/trunk/cumin/python/cumin/job.py
mgmt/trunk/cumin/python/cumin/limits.py
mgmt/trunk/cumin/python/cumin/model.py
Log:
Moving method calls to model.py in case we want to call them using call.xml in the future.
Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py 2008-10-08 15:46:34 UTC (rev 2606)
+++ mgmt/trunk/cumin/python/cumin/job.py 2008-10-08 18:30:55 UTC (rev 2607)
@@ -529,25 +529,8 @@
return items
def get_raw_ads(self, session, job):
- self.job_ads = {"":{"VALUE": "", "TYPE": 0}}
- self.got_data = False
-
- def completion(status, job_ads):
- self.job_ads = job_ads["JobAd"]
- self.got_data = True
-
- def predicate():
- return self.got_data
-
- try:
- model = self.app.model
- job.GetAd(model.data, completion, self.job_ads)
- except:
- return self.job_ads
-
- # wait for up to 20 seconds for completion to be called
- wait(predicate, timeout=20)
- return self.job_ads
+ action = self.app.model.job.getad
+ return action.do_invoke(job)
def gen_items(self, session, job):
job_ads = self.get_raw_ads(session, job)
@@ -836,48 +819,18 @@
is_tail = self.first_last.get(session) == "t"
return is_tail and "<script language=\"javascript\" type=\"text/javascript\">addEvent(window, \"load\", outputEnd);</script>" or ""
- def render_the_output(self, session, *args):
- self.job_output = None
- self.got_data = False
-
- def completion(status, job_output):
- if "Data" in job_output:
- raw = job_output["Data"]
- self.job_output = fix_raw(raw)
- self.got_data = True
-
- def predicate():
- return self.got_data
-
- def fix_raw(raw):
- """ remove the last partial line from the buffer
-
- This is done because the buffer ends with non-ascii junk characters
- """
- lindex = -1
- ord_nl = ord('\n')
- while ord(raw[-lindex:][0]) != ord_nl:
- lindex = lindex + 1
- return raw[:-lindex]
-
+ def render_the_output(self, session, job):
first_last = self.first_last.get(session)
- start = first_last == "t" and -2048 or 0
- end = first_last == "t" and 0 or 2048
+ if first_last == "t":
+ start = -2048
+ end = 0
+ else:
+ start = 0
+ end = 2048
file = self.which_file.get_current_file_name(session)
if file:
- try:
- model = self.app.model
- job = args[0]
- data = dict()
- job.Fetch(model.data, completion, file, start, end, data)
- # wait for up to 20 seconds for completion to be called
- wait(predicate, timeout=20)
- if not self.got_data:
- self.job_output = "Unable to get file at %s. Reason: time out" % file
- except Exception, e:
- self.job_output = "Unable to get file at %s. Reason: %s" % (file, e)
-
- return self.job_output and escape_entity(self.job_output)
+ action = self.app.model.job.fetch
+ return action.do_invoke(job, file, start, end)
class FetchButton(FormButton):
def render_content(self, session):
Modified: mgmt/trunk/cumin/python/cumin/limits.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.py 2008-10-08 15:46:34 UTC (rev 2606)
+++ mgmt/trunk/cumin/python/cumin/limits.py 2008-10-08 18:30:55 UTC (rev 2607)
@@ -41,25 +41,8 @@
negotiator.Reconfig(self.app.model.data, completion)
def get_raw_limits(self, session, negotiator):
- self.lim = dict()
- self.got_data = False
-
- def completion(status, data):
- self.lim = data["Limits"]
- self.got_data = True
-
- def predicate():
- return self.got_data
-
- try:
- model = self.app.model
- negotiator.GetLimits(model.data, completion, self.lim)
- except:
- return self.lim
-
- # wait for up to 20 seconds for completion to be called
- wait(predicate, timeout=5)
- return self.lim
+ action = self.app.model.negotiator.GetLimits
+ return action.do_invoke(negotiator)
class LimitsSet(ItemTable, LimitActions):
def __init__(self, app, name):
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-10-08 15:46:34 UTC (rev 2606)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-10-08 18:30:55 UTC (rev 2607)
@@ -1865,6 +1865,12 @@
action = self.SetAttribute(self, "setattribute")
action.navigable = False
+ action = self.GetAd(self, "getad")
+ action.navigable = False
+
+ action = self.Fetch(self, "fetch")
+ action.navigable = False
+
def get_title(self, session):
return "Job"
@@ -1924,6 +1930,58 @@
return escape_amp(fmt_olink(branch, scheduler, name=scheduler.Name))
+ class GetAd(CuminAction):
+ def do_invoke(self, job):
+ self.job_ads = {"":{"VALUE": "", "TYPE": 0}}
+ self.got_data = False
+
+ def completion(status, job_ads):
+ self.job_ads = job_ads["JobAd"]
+ self.got_data = True
+
+ def predicate():
+ return self.got_data
+
+ try:
+ job.GetAd(self.cumin_model.data, completion, self.job_ads)
+ except:
+ return self.job_ads
+
+ # wait for up to 20 seconds for completion to be called
+ wait(predicate, timeout=20)
+ return self.job_ads
+
+ class Fetch(CuminAction):
+ def do_invoke(self, job, file, start, end):
+ self.job_output = None
+ self.got_data = False
+
+ def completion(status, job_output):
+ if "Data" in job_output:
+ raw = job_output["Data"]
+ #remove the last partial line from the buffer
+ lindex = -1
+ ord_nl = ord('\n')
+ while ord(raw[-lindex:][0]) != ord_nl:
+ lindex = lindex + 1
+ self.job_output = raw[:-lindex]
+ self.got_data = True
+
+ def predicate():
+ return self.got_data
+
+ try:
+ data = dict()
+ job.Fetch(self.cumin_model.data, completion, file, start, end, data)
+ # wait for up to 20 seconds for completion to be called
+ wait(predicate, timeout=20)
+ if not self.got_data:
+ self.job_output = "Unable to get file at %s. Reason: time out" % file
+ except Exception, e:
+ self.job_output = "Unable to get file at %s. Reason: %s" % (file, e)
+
+ return self.job_output and escape_entity(self.job_output)
+
class Hold(CuminAction):
def show(self, session, job):
frame = self.cumin_class.get_pool_frame(session)
@@ -2213,7 +2271,11 @@
action = self.Stop(self, "stop")
action.summary = True
+ action = self.GetLimits(self, "GetLimits")
+ action.navigable = False
+
action = self.GetLimitCount(self, "GetLimitCount")
+ action.navigable = False
def get_title(self, session):
return "Negotiator"
@@ -2258,11 +2320,12 @@
negotiator.Stop(self.cumin_model.data, completion)
class GetLimitCount(CuminAction):
- def __init__(self, cls, name):
- super(CuminNegotiator.GetLimitCount, self).__init__(cls, name)
+ def do_invoke(self, negotiator):
+ action = self.cumin_model.negotiator.GetLimits
+ limits = action.do_invoke(negotiator)
+ return "<count value=\"%i\" />" % len(limits)
- self.navigable = False
-
+ class GetLimits(CuminAction):
def do_invoke(self, negotiator):
self.lim = dict()
self.got_data = False
@@ -2281,7 +2344,7 @@
# wait for up to 5 seconds for completion to be called
wait(predicate, timeout=5)
- return "<count value=\"%i\" />" % len(self.lim)
+ return self.lim
class ModelPage(Page):
def __init__(self, app, name):
16 years, 2 months
rhmessaging commits: r2606 - in mgmt/trunk/cumin/python: wooly and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-10-08 11:46:34 -0400 (Wed, 08 Oct 2008)
New Revision: 2606
Added:
mgmt/trunk/cumin/python/cumin/modelwidgets.py
mgmt/trunk/cumin/python/cumin/modelwidgets.strings
Modified:
mgmt/trunk/cumin/python/cumin/brokergroup.py
mgmt/trunk/cumin/python/cumin/brokergroup.strings
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/page.py
mgmt/trunk/cumin/python/cumin/parameters.py
mgmt/trunk/cumin/python/cumin/widgets.py
mgmt/trunk/cumin/python/cumin/widgets.strings
mgmt/trunk/cumin/python/wooly/__init__.py
mgmt/trunk/cumin/python/wooly/forms.py
mgmt/trunk/cumin/python/wooly/forms.strings
mgmt/trunk/cumin/python/wooly/tables.py
mgmt/trunk/cumin/python/wooly/widgets.py
mgmt/trunk/cumin/python/wooly/widgets.strings
Log:
First step toward model driven table views, to avoid the present
duplication of table view code, and to achieve more uniform
presentation.
* Introduces modelwidgets.py to cumin, a set of standard model-driven
widgets.
* Add a CuminSetAction to cumin model, for describing actions on sets
of objects
* Switch BrokerGroupSet over to the new model widget for tables
* Add group set remove functionality
Other:
* Add a CuminTableWithControls, which renders a CuminTable with
filters and switches included
* Remove field set in favor of putting that functionality directly in
field form
* Adds a SqlTableFilter class to wooly tables.py
* Added an html_class attr to Widget, to set the value returned by
render_class
* Added a WidgetSet widget, which by default produces an unordered
list of its children
Modified: mgmt/trunk/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/brokergroup.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/cumin/brokergroup.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -4,42 +4,24 @@
from wooly.forms import *
from broker import BrokerSet
+from model import *
from widgets import *
+from modelwidgets import *
from parameters import *
from formats import *
from util import *
strings = StringCatalog(__file__)
-class BrokerGroupSet(CuminTable):
+class BrokerGroupSet(CuminClassTable):
def __init__(self, app, name):
- super(BrokerGroupSet, self).__init__(app, name)
+ cls = app.model.broker_group
- col = self.NameColumn(app, "name")
+ super(BrokerGroupSet, self).__init__(app, name, cls)
+
+ col = CuminClassNameColumn(app, "name", cls)
self.add_column(col)
- #col = self.StatusColumn(app, "status")
- #self.add_column(col)
-
- def render_title(self, session):
- return "Broker Groups %s" % fmt_count(BrokerGroup.select().count())
-
- def render_group_add_href(self, session):
- branch = session.branch()
- self.frame.show_broker_group(branch, None).show_add(branch)
- return branch.marshal()
-
- class NameColumn(SqlTableColumn):
- def render_title(self, session, data):
- return "Name"
-
- def render_content(self, session, data):
- group = Identifiable(data["id"])
- branch = session.branch()
- frame = self.app.model.broker_group.show_object(branch, group)
- frame = frame.show_view(branch)
- return fmt_olink(branch, group, name=data["name"])
-
class BrokerGroupInputSet(CheckboxInputSet):
def __init__(self, app, name):
super(BrokerGroupInputSet, self).__init__(app, name, None)
Modified: mgmt/trunk/cumin/python/cumin/brokergroup.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/brokergroup.strings 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/cumin/brokergroup.strings 2008-10-08 15:46:34 UTC (rev 2606)
@@ -6,21 +6,3 @@
[BrokerGroupSet.count_sql]
select count(*) from broker_group
-
-[BrokerGroupSet.html]
-<ul class="actions">
- <li><a class="nav" href="{group_add_href}">Add Broker Group</a></li>
-</ul>
-
-<table class="mobjects">
- <thead>
- <tr>
- <th class="setnav" colspan="0">
- <div class="rfloat">{page}</div>
- {count}
- </th>
- </tr>
- <tr>{headers}</tr>
- </thead>
- <tbody>{items}</tbody>
-</table>
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -1,3 +1,4 @@
+import logging
from mint.schema import *
from wooly import *
from wooly.parameters import *
@@ -5,7 +6,6 @@
from time import *
from datetime import datetime, timedelta
from types import *
-from logging import getLogger
from struct import unpack
from util import *
@@ -13,7 +13,7 @@
from parameters import *
from job import *
-log = getLogger("cumin.model")
+log = logging.getLogger("cumin.model")
class CuminModel(object):
def __init__(self, app, data_uri, spec_path):
@@ -24,7 +24,7 @@
self.invocations = set()
# Messaging
-
+
CuminBroker(self)
CuminQueue(self)
CuminExchange(self)
@@ -173,6 +173,7 @@
self.title = None
self.summary = False
self.navigable = True
+ self.aggregate = False
self.cumin_class.add_action(self)
@@ -190,7 +191,13 @@
return self.title
else:
return self.name
-
+
+ def get_summary(self, session, object):
+ pred0 = self.get_title(session)
+ pred1 = self.cumin_class.get_object_title(session, object)
+
+ return "%s %s" % (pred0, pred1)
+
def get_enabled(self, session, object):
return True
@@ -232,7 +239,6 @@
return conn.mconn.session(str(uuid4()))
-
class CuminActionInvocation(object):
def __init__(self, action, object):
self.action = action
@@ -258,6 +264,18 @@
print "action", self.action.name, self.object, self.when, \
self.status, self.args, self.exception
+class CuminSetAction(CuminAction):
+ def __init__(self, cls, name):
+ super(CuminSetAction, self).__init__(cls, name)
+
+ self.aggregate = True
+
+ def get_summary(self, session, object):
+ pred0 = self.get_title(session)
+ pred1 = self.cumin_class.get_plural_title(session)
+
+ return "%s %s" % (pred0, pred1)
+
class CuminStat(object):
def __init__(self, cls, name):
self.cumin_model = cls.cumin_model
@@ -405,14 +423,20 @@
def get_title(self, session):
return "Object"
+ def get_plural_title(self, session):
+ return self.get_title(session) + "s"
+
def get_icon_href(self, session):
return "resource?name=action-36.png"
def get_object_href(self, session, object):
branch = session.branch()
- self.show_object(branch, object)
+ self.show_object(branch, object).show_view(branch)
return branch.marshal()
+ def get_object_href_by_id(self, session, id):
+ return self.get_object_href(session, Identifiable(id))
+
def show_object(self, session, object):
raise Exception("Not implemented")
@@ -1505,6 +1529,11 @@
super(CuminBrokerGroup, self).__init__ \
(model, "broker_group", BrokerGroup)
+ self.add.title = "Add Group"
+
+ action = self.RemoveSet(self, "remove_set")
+ action.title = "Remove"
+
def show_object(self, session, group):
frame = self.cumin_model.show_main(session)
return frame.show_broker_group(session, group)
@@ -1515,6 +1544,18 @@
def get_icon_href(self, session):
return "resource?name=group-36.png"
+ class RemoveSet(CuminSetAction):
+ def show(self, session, groups):
+ frame = self.cumin_model.show_main(session)
+ return frame.show_broker_groups_remove(session, groups)
+
+ def do_invoke(self, groups, args, completion):
+ for group in groups:
+ group.destroySelf()
+ group.syncUpdate()
+
+ completion("yo!")
+
class CuminPool(CuminClass):
def __init__(self, model):
super(CuminPool, self).__init__ \
@@ -2137,7 +2178,7 @@
class CuminNegotiator(RemoteClass):
def __init__(self, model):
super(CuminNegotiator, self).__init__(model, "negotiator",
- Negotiator, NegotiatorStats)
+ Negotiator, NegotiatorStats)
prop = CuminProperty(self, "Name")
prop.title = "Name"
@@ -2215,7 +2256,7 @@
def do_invoke(self, negotiator, args, completion):
negotiator.Stop(self.cumin_model.data, completion)
-
+
class GetLimitCount(CuminAction):
def __init__(self, cls, name):
super(CuminNegotiator.GetLimitCount, self).__init__(cls, name)
Added: mgmt/trunk/cumin/python/cumin/modelwidgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/modelwidgets.py (rev 0)
+++ mgmt/trunk/cumin/python/cumin/modelwidgets.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -0,0 +1,179 @@
+from wooly import *
+from wooly.forms import *
+
+from model import *
+from widgets import *
+from util import *
+
+from wooly.widgets import Link
+
+strings = StringCatalog(__file__)
+
+class CuminActionButton(FormButton):
+ def __init__(self, app, name, action, object=None):
+ super(CuminActionButton, self).__init__(app, name)
+
+ self.action = action
+ self.object = object
+
+ def process_submit(self, session, *args):
+ branch = session.branch()
+ object = None
+
+ if self.object:
+ object = self.object.get(session)
+
+ self.action.show(branch, object)
+
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def render_content(self, session, *args):
+ return self.action.get_title(session)
+
+class CuminActionLink(Link):
+ def __init__(self, app, name, action, object=None):
+ super(CuminActionLink, self).__init__(app, name)
+
+ self.action = action
+ self.object = object
+
+ def edit_session(self, session, *args):
+ object = None
+
+ if self.object:
+ object = self.object.get(session)
+
+ self.action.show(session, object)
+
+ def render_content(self, session, *args):
+ return self.action.get_title(session)
+
+class CuminActionForm(CuminFieldForm):
+ def __init__(self, app, name, action, object=None):
+ super(CuminActionForm, self).__init__(app, name)
+
+ self.action = action
+ self.object = object
+
+ def render_title(self, session, *args):
+ return self.action.get_summary(session, self.object.get(session))
+
+ def process_submit(self, session, *args):
+ object = None
+
+ if self.object:
+ object = self.object.get(session)
+
+ self.action.invoke(object)
+
+ self.process_cancel(session, *args)
+
+class CuminSetActionForm(CuminForm):
+ def __init__(self, app, name, action, object):
+ super(CuminSetActionForm, self).__init__(app, name)
+
+ assert isinstance(action, CuminAction)
+ assert action.aggregate
+ assert isinstance(object, Parameter)
+
+ self.action = action
+
+ self.objects = ListParameter(app, "param", object)
+ self.add_parameter(self.objects)
+
+ body = self.SetActionBody(app, "body")
+ self.add_child(body)
+
+ def render_title(self, session, *args):
+ return self.action.get_summary(session, self.objects.get(session))
+
+ def process_submit(self, session, *args):
+ self.action.invoke(self.objects.get(session))
+
+ self.process_cancel(session, *args)
+
+ class SetActionBody(ItemSet):
+ def render_message(self, session, *args):
+ verb = self.parent.action.get_title(session)
+ noun = self.parent.action.cumin_class.get_plural_title(session)
+
+ return "%s the following %s" % (verb, noun)
+
+ def do_get_items(self, session, *args):
+ return self.parent.objects.get(session)
+
+ def render_item_content(self, session, item):
+ cls = self.parent.action.cumin_class
+ return cls.get_object_title(session, item)
+
+class CuminClassTable(CuminTableWithControls, Form):
+ def __init__(self, app, name, cumin_class):
+ super(CuminClassTable, self).__init__(app, name)
+
+ self.cumin_class = cumin_class
+
+ self.selection = CuminClassCheckboxColumn(app, "id", self.cumin_class)
+ self.add_column(self.selection)
+
+ self.actions = WidgetSet(app, "actions")
+ self.actions.html_class = "actions"
+ self.add_child(self.actions)
+
+ actions = [x for x in self.cumin_class.actions if x.aggregate]
+
+ for action in actions:
+ button = CuminActionButton \
+ (app, action.name, action, self.selection.param)
+ self.actions.add_child(button)
+
+ self.add = None
+
+ if hasattr(self.cumin_class, "add"):
+ self.add = CuminActionLink(app, "add", self.cumin_class.add)
+ self.add.html_class = "action"
+ self.add_child(self.add)
+
+ def render_title(self, session, *args):
+ title = self.cumin_class.get_plural_title(session)
+ count = fmt_count(self.cumin_class.mint_class.select().count())
+
+ return "%s %s" % (title, count)
+
+ def render_plural_title(self, session, *args):
+ return self.cumin_class.get_plural_title(session)
+
+ def render_add_link(self, session, *args):
+ if self.add:
+ return self.add.render(session, *args)
+
+ def render_actions(self, session, *args):
+ if self.actions.children:
+ return self.actions.render(session, *args)
+
+class CuminClassCheckboxColumn(CheckboxInputColumn):
+ def __init__(self, app, name, cumin_class):
+ item = CuminObjectParameter(app, "item", cumin_class)
+
+ super(CuminClassCheckboxColumn, self).__init__(app, name, item)
+
+ self.cumin_class = cumin_class
+
+class CuminClassNameColumn(SqlTableColumn):
+ def __init__(self, app, name, cumin_class):
+ super(CuminClassNameColumn, self).__init__(app, name)
+
+ self.cumin_class = cumin_class
+
+ self.id_column = "id"
+ self.name_column = "name"
+
+ def render_title(self, session, data):
+ return "Name"
+
+ def render_content(self, session, data):
+ id = data[self.id_column]
+ name = data[self.name_column]
+
+ href = self.cumin_class.get_object_href_by_id(session, id)
+
+ return fmt_link(href, name)
Added: mgmt/trunk/cumin/python/cumin/modelwidgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/modelwidgets.strings (rev 0)
+++ mgmt/trunk/cumin/python/cumin/modelwidgets.strings 2008-10-08 15:46:34 UTC (rev 2606)
@@ -0,0 +1,43 @@
+[SetActionBody.html]
+<h2>{message}</h2>
+<ul>{items}</ul>
+
+[CuminClassTable.css]
+.CuminClassTable div.addlink {
+ margin: 0 0 1em 0;
+}
+
+.CuminClassTable ul.actions {
+ margin: 0;
+ display: inline;
+}
+
+.CuminClassTable ul.actions li {
+ display: inline;
+}
+
+[CuminClassTable.html]
+<form class="CuminClassTable" id="{id}" method="post" action="?">
+ <div class="addlink">{add_link}</div>
+
+ {switches}
+
+ {filters}
+
+ <div class="sactions">Act on Selected {plural_title}: {actions}</div>
+
+ <table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
+ </table>
+
+ <div>{hidden_inputs}</div>
+</form>
Modified: mgmt/trunk/cumin/python/cumin/page.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/page.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/cumin/page.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -65,6 +65,12 @@
self.__group = BrokerGroupFrame(app, "group")
self.add_mode(self.__group)
+ action = self.app.model.broker_group.remove_set
+ item = BrokerGroupParameter(app, "item")
+ self.__groups_remove = CuminSetActionForm \
+ (app, "groupsremove", action, item)
+ self.add_mode(self.__groups_remove)
+
self.__profile = BrokerProfileFrame(app, "profile")
self.add_mode(self.__profile)
@@ -144,6 +150,11 @@
frame.set_object(session, group)
return self.page.set_current_frame(session, frame)
+ def show_broker_groups_remove(self, session, groups):
+ frame = self.show_mode(session, self.__groups_remove)
+ frame.objects.set(session, groups)
+ return self.page.set_current_frame(session, frame)
+
def show_broker_profile(self, session, profile):
frame = self.show_mode(session, self.__profile)
frame.set_object(session, profile)
Modified: mgmt/trunk/cumin/python/cumin/parameters.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/parameters.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/cumin/parameters.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -1,6 +1,16 @@
from wooly import *
from mint import *
+class CuminObjectParameter(Parameter):
+ def __init__(self, app, name, cumin_class):
+ self.cumin_class = cumin_class
+
+ def do_unmarshal(self, string):
+ return self.cumin_class.mint_class.get(int(string))
+
+ def do_marshal(self, object):
+ return str(object.id)
+
class CuminClassParameter(Parameter):
def do_unmarshal(self, string):
return getattr(self.app.model, string, None)
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -204,6 +204,9 @@
def render_submit_content(self, session, *args):
return "Submit"
+ def render_form_error(self, session, *args):
+ pass
+
class Cancel(FormButton):
def render_class(self, session, *args):
return "cancel"
@@ -225,9 +228,9 @@
return "resource?name=help.html#%s" % self.path
class CuminFieldForm(CuminForm, FieldForm, Frame):
- def render_form_error(self, session, *args):
- pass
-
+ def render_body(self, session, *args):
+ return self.render_fields(session, *args)
+
class CuminConfirmForm(CuminForm):
def __init__(self, app, name):
super(CuminConfirmForm, self).__init__(app, name)
@@ -453,8 +456,10 @@
def do_get_items(self, session, object):
cls = self.app.model.get_class_by_object(object)
- return [(x.get_href(session, object), x.get_title(session), x.get_enabled(session, object))
- for x in cls.actions if x.navigable]
+ return [(x.get_href(session, object),
+ x.get_title(session),
+ x.get_enabled(session, object))
+ for x in cls.actions if x.navigable and not x.aggregate]
class CuminDetails(Widget):
def __init__(self, app, name):
@@ -617,6 +622,43 @@
start, end = self.paginator.get_bounds(session)
return "limit %i offset %i" % (end - start, start)
+class CuminTableWithControls(CuminTable):
+ def __init__(self, app, name):
+ super(CuminTableWithControls, self).__init__(app, name)
+
+ self.switches = WidgetSet(app, "switches")
+ self.switches.html_class = "switches"
+ self.add_child(self.switches)
+
+ self.filters = WidgetSet(app, "filters")
+ self.filters.html_class = "filters"
+ self.add_child(self.filters)
+
+ def get_sql_constraint(self, session, *args):
+ pass
+
+ def render_switches(self, session, *args):
+ if self.switches.children:
+ return self.switches.render(session, *args)
+
+ def render_filters(self, session, *args):
+ if self.filters.children:
+ return self.filters.render(session, *args)
+
+ def render_sql_where(self, session, *args):
+ constraints = list()
+
+ for filter in self.filters.children:
+ if filter:
+ constraints.append(filter.get_sql_constraint(session, *args))
+
+ constraint = self.get_sql_constraint(session, *args)
+
+ if constraint:
+ constraints.append(constraint)
+
+ return "where %s" % " and ".join(constraints)
+
class NullSortColumn(SqlTableColumn):
def get_orderby_sql(self, session):
key = self.get_column_key(session)
@@ -755,6 +797,24 @@
binding = Binding.get(data["id"])
return self.app.model.binding.msgMatched.value(binding)
+class CheckboxInputColumn(FormInput, ItemTableColumn):
+ def __init__(self, app, name, item_param):
+ super(CheckboxInputColumn, self).__init__(app, name, None)
+
+ self.header_class = CheckboxIdColumnHeader
+
+ self.param = ListParameter(app, "param", item_param)
+ self.add_parameter(self.param)
+
+ def do_render(self, session, data):
+ name = self.param.path
+ id = data[self.name]
+ attr = id in self.param.get(session) and "checked=\"checked\"" or ""
+ html = "<td><input type=\"checkbox\" name=\"%s\" " + \
+ "value=\"%i\" %s/></td>"
+
+ return html % (name, id, attr)
+
class CheckboxIdColumn(FormInput, SqlTableColumn):
def __init__(self, app, name):
super(CheckboxIdColumn, self).__init__(app, name, None)
Modified: mgmt/trunk/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.strings 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/cumin/widgets.strings 2008-10-08 15:46:34 UTC (rev 2606)
@@ -551,13 +551,13 @@
{tabs}
-[CuminFieldForm.html]
+[CuminForm.html]
<form id="{id}" class="mform" method="post" action="?">
<div class="head">{title}</div>
- <div class="body">{fields}</div>
+ <div class="body">{body}</div>
{form_error}
<div class="foot">
- {help}
+ {help}
{submit}
{cancel}
</div>
@@ -907,6 +907,29 @@
<tbody>{items}</tbody>
</table>
+[CuminTableWithControls.html]
+<div class="CuminTable">
+ {switches}
+
+ {filters}
+
+ <table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ <div class="rfloat">{page}</div>
+
+ {count}
+ </th>
+ </tr>
+
+ <tr>{headers}</tr>
+ </thead>
+
+ <tbody>{items}</tbody>
+ </table>
+</div>
+
[TableHeader.css]
th.selected a {
color: black;
Modified: mgmt/trunk/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/__init__.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/wooly/__init__.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -108,6 +108,8 @@
if cls is Widget:
break
+ self.html_class = "_"
+
self.sealed = False
def init(self):
@@ -246,7 +248,7 @@
return self.path
def render_class(self, session, *args):
- return "noclass"
+ return self.html_class
def render_href(self, session, *args):
return session.marshal()
Modified: mgmt/trunk/cumin/python/wooly/forms.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/forms.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/wooly/forms.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -112,7 +112,9 @@
def init(self):
super(FormInput, self).init()
- assert self.param is not None
+ if self.param is None:
+ raise Exception("Parameter not set for %s" % self)
+
assert isinstance(self.param, Parameter)
for anc in self.ancestors:
@@ -263,26 +265,6 @@
def render_item_selected_attr(self, session, item):
return None
-class FieldSet(Widget):
- def __init__(self, app, name):
- super(FieldSet, self).__init__(app, name)
-
- self.fields = list()
-
- def add_field(self, field):
- assert isinstance(field, FormField)
-
- self.fields.append(field)
- self.add_child(field)
-
- def render_fields(self, session, *args):
- writer = Writer()
-
- for field in self.fields:
- writer.write(field.render(session))
-
- return writer.to_string()
-
class FormField(Widget):
def __init__(self, app, name):
super(FormField, self).__init__(app, name)
@@ -395,10 +377,18 @@
return writer.to_string()
-class FieldForm(Form, FieldSet):
+class FieldForm(Form):
def __init__(self, app, name):
super(FieldForm, self).__init__(app, name)
+ self.fields = list()
+
+ def add_field(self, field):
+ assert isinstance(field, FormField)
+
+ self.fields.append(field)
+ self.add_child(field)
+
def validate(self, session):
errors = list()
@@ -406,3 +396,11 @@
errors.extend(field.validate(session))
return errors
+
+ def render_fields(self, session, *args):
+ writer = Writer()
+
+ for field in self.fields:
+ writer.write(field.render(session))
+
+ return writer.to_string()
Modified: mgmt/trunk/cumin/python/wooly/forms.strings
===================================================================
--- mgmt/trunk/cumin/python/wooly/forms.strings 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/wooly/forms.strings 2008-10-08 15:46:34 UTC (rev 2606)
@@ -49,12 +49,6 @@
[OptionInputSet.item_html]
<option value="{item_value}" {item_selected_attr}>{item_content}</option>
-[FieldSet.html]
-<div class="fieldset">
- <div class="title">{title}</div>
- <div class="fields">{fields}</div>
-</div>
-
[FormField.css]
div.field {
padding: 0;
@@ -84,9 +78,3 @@
tabindex="{tab_index}" {checked_attr} {disabled_attr}/>
<label for="{id}">{title}</label>
</div>
-
-[FieldForm.html]
-<form id="{id}">
- {fields}
- <div>{hidden_inputs}</div>
-</form>
Modified: mgmt/trunk/cumin/python/wooly/tables.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/tables.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/wooly/tables.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -128,7 +128,7 @@
def render_value(self, session, value):
return str(value)
- # in case a non-sql column is included in an sqltable
+ # in case a non-sql column is included in an sqltable # XXX ugh
def get_orderby_sql(self, session):
pass
@@ -259,6 +259,9 @@
return writer.to_string()
class SqlTableColumn(ItemTableColumn):
+ # XXX to be consistent with similar methods, rename to
+ # get_sql_order_by
+
def get_orderby_sql(self, session):
key = self.get_column_key(session)
@@ -266,7 +269,6 @@
dir = self.parent.is_reversed(session) and "desc" or "asc"
return "order by %s %s" % (key, dir)
-class CheckboxColumn(SqlTableColumn):
- def do_render(self, session, data):
- return "<td><input type=\"checkbox\" name=\"%s\"/></td>" % \
- data[self.name]
+class SqlTableFilter(Widget):
+ def get_sql_constraint(self, session, *args):
+ pass
Modified: mgmt/trunk/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/widgets.py 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/wooly/widgets.py 2008-10-08 15:46:34 UTC (rev 2606)
@@ -81,6 +81,25 @@
args = tab.get_args(session)
return tab.render_title(session, *args)
+class WidgetSet(Widget):
+ def __init__(self, app, name):
+ super(WidgetSet, self).__init__(app, name)
+
+ self.__widget_tmpl = Template(self, "widget_html")
+
+ def render_widgets(self, session, *args):
+ writer = Writer()
+
+ for widget in self.children:
+ self.__widget_tmpl.render(writer, session, widget)
+
+ return writer.to_string()
+
+ def render_widget(self, session, widget):
+ return widget.render(session)
+
+# XXX get rid of this, now that we have the slightly more general
+# WidgetSet
class LinkSet(Widget):
def __init__(self, app, name):
super(LinkSet, self).__init__(app, name)
@@ -459,4 +478,4 @@
t += "&" + name + ";"
else:
t += i
- return t
\ No newline at end of file
+ return t
Modified: mgmt/trunk/cumin/python/wooly/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/wooly/widgets.strings 2008-10-08 13:28:37 UTC (rev 2605)
+++ mgmt/trunk/cumin/python/wooly/widgets.strings 2008-10-08 15:46:34 UTC (rev 2606)
@@ -49,6 +49,12 @@
[TabbedModeSet.tab_html]
<li><a href="{tab_href}" {tab_class}>{tab_content}</a></li>
+[WidgetSet.html]
+<ul class="{class}">{widgets}</ul>
+
+[WidgetSet.widget_html]
+<li>{widget}</li>
+
[LinkSet.html]
<ul class="{class}">{links}</ul>
16 years, 2 months
rhmessaging commits: r2605 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2008-10-08 09:28:37 -0400 (Wed, 08 Oct 2008)
New Revision: 2605
Modified:
mgmt/trunk/cumin/python/cumin/__init__.py
mgmt/trunk/cumin/python/cumin/limits.py
mgmt/trunk/cumin/python/cumin/model.py
Log:
Rename data.xml to call.xml
Modified: mgmt/trunk/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/__init__.py 2008-10-08 13:23:08 UTC (rev 2604)
+++ mgmt/trunk/cumin/python/cumin/__init__.py 2008-10-08 13:28:37 UTC (rev 2605)
@@ -11,8 +11,7 @@
from time import sleep
from threading import Thread, Event
from urllib import quote
-
-from model import CuminModel, ModelPage, DataPage
+from model import CuminModel, ModelPage, CallPage
from demo import DemoData
from page import MainPage
from stat import StatChartPage
@@ -51,7 +50,7 @@
self.add_page(DevelPage(self, "devel.html"))
self.add_page(ModelPage(self, "model.xml"))
- self.add_page(DataPage(self, "data.xml"))
+ self.add_page(CallPage(self, "call.xml"))
self.add_page(ActionPage(self, "actions.html"))
self.add_page(StatChartPage(self, "stats.png"))
Modified: mgmt/trunk/cumin/python/cumin/limits.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.py 2008-10-08 13:23:08 UTC (rev 2604)
+++ mgmt/trunk/cumin/python/cumin/limits.py 2008-10-08 13:28:37 UTC (rev 2605)
@@ -96,7 +96,7 @@
def get_url(self, session):
negotiator = self.parent.get_negotiator(session)
if negotiator:
- return "data.xml?class=negotiator;id=%i;method=GetLimitCount" % negotiator.id
+ return "call.xml?class=negotiator;id=%i;method=GetLimitCount" % negotiator.id
def get_title(self, session, title):
return "%s <span id=\"%s\">%s</span>" % \
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-10-08 13:23:08 UTC (rev 2604)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-10-08 13:28:37 UTC (rev 2605)
@@ -2273,9 +2273,9 @@
return writer.to_string()
-class DataPage(Page):
+class CallPage(Page):
def __init__(self, app, name):
- super(DataPage, self).__init__(app, name)
+ super(CallPage, self).__init__(app, name)
self.__class = CuminClassParameter(app, "class")
self.add_parameter(self.__class)
16 years, 2 months
rhmessaging commits: r2604 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2008-10-08 09:23:08 -0400 (Wed, 08 Oct 2008)
New Revision: 2604
Modified:
mgmt/trunk/cumin/python/cumin/limits.py
Log:
Removed old limit_count method in favor of new AjaxField object
Modified: mgmt/trunk/cumin/python/cumin/limits.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/limits.py 2008-10-07 22:20:45 UTC (rev 2603)
+++ mgmt/trunk/cumin/python/cumin/limits.py 2008-10-08 13:23:08 UTC (rev 2604)
@@ -92,13 +92,6 @@
def render_title(self, session):
return self.limit_count.get_title(session, "Concurrency Limits")
- def limit_count(self, session):
- limits = self.limits.get(session)
- if not limits:
- limits = self.fetch_limits(session)
- 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)
16 years, 2 months
rhmessaging commits: r2603 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
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; */
16 years, 2 months