Author: eallen
Date: 2008-11-11 11:16:53 -0500 (Tue, 11 Nov 2008)
New Revision: 2784
Modified:
mgmt/trunk/cumin/python/cumin/brokerlink.py
mgmt/trunk/cumin/python/cumin/exchange.py
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/queue.py
mgmt/trunk/cumin/python/cumin/widgets.py
Log:
Cleaning up TwoOptionRadioField. Now gets option1 and option2 titles from a dynamic
context for future i18n support.
Modified: mgmt/trunk/cumin/python/cumin/brokerlink.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/brokerlink.py 2008-11-11 15:57:53 UTC (rev 2783)
+++ mgmt/trunk/cumin/python/cumin/brokerlink.py 2008-11-11 16:16:53 UTC (rev 2784)
@@ -433,19 +433,19 @@
self.excludes.set(session, "%s:%s" % (args[0].host, args[0].port))
class DynamicField(TwoOptionRadioField):
- def __init__(self, app, name, option1="yes", option2="no"):
- super(BridgeAddForm.DynamicField, self).__init__(app, name, option1,
option2)
-
- self.option1_title = "Dynamic"
- self.option2_title = "Not dynamic"
- self.param.default = option2
-
def render_title(self, session):
return "Dynamic Route?"
def render_field_help(self, session):
return "(Should the added route be dynamic)"
+ def render_title_1(self, session):
+ return "Dynamic"
+
+ def render_title_2(self, session):
+ return "Not dynamic"
+
+
class BridgeAddHelpField(FormField):
pass
@@ -589,19 +589,18 @@
return "rdma"
class DurableField(TwoOptionRadioField):
- def __init__(self, app, name, option1="yes", option2="no"):
- super(BrokerLinkAddForm.DurableField, self).__init__(app, name, option1,
option2)
-
- self.option1_title = "Yes, restore if broker restarts"
- self.option2_title = "No, do not restore if broker restarts"
- self.param.default = option2
-
def render_title(self, session):
return "Restore if broker restarts?"
def render_field_help(self, session):
return "(Should the added configuration be durable)"
+ def render_title_1(self, session):
+ return "Yes, restore if broker restarts"
+
+ def render_title_2(self, session):
+ return "No, do not restore if broker restarts"
+
class BrokerLinkAdd(BrokerLinkAddForm):
def process_cancel(self, session):
branch = session.branch()
Modified: mgmt/trunk/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/exchange.py 2008-11-11 15:57:53 UTC (rev 2783)
+++ mgmt/trunk/cumin/python/cumin/exchange.py 2008-11-11 16:16:53 UTC (rev 2784)
@@ -359,47 +359,44 @@
self.more.add_field(self.ive)
class SequenceField(TwoOptionRadioField):
- def __init__(self, app, name, option1="yes", option2="no"):
- super(ExchangeForm.SequenceField, self).__init__(app, name, option1,
option2)
-
- self.option1_title = "Insert Sequence"
- self.option2_title = "No Sequence"
- self.param.default = "no"
-
def render_title(self, session):
return "Insert Sequence?"
def render_field_help(self, session):
return "(Exchange will insert a 'qpid.msg_sequence' field in the
message header)"
- class IVEField(TwoOptionRadioField):
- def __init__(self, app, name, option1="yes", option2="no"):
- super(ExchangeForm.IVEField, self).__init__(app, name, option1, option2)
+ def render_title_1(self, session):
+ return "Insert Sequence"
- self.option1_title = "Initial-Value-Exchange"
- self.option2_title = "No IVE"
- self.param.default = "no"
+ def render_title_2(self, session):
+ return "No Sequence"
+ class IVEField(TwoOptionRadioField):
def render_title(self, session):
return "Initial Value Exchange?"
def render_field_help(self, session):
return "(Exchange will behave as an 'initial-value-exchange',
keeping a reference to the last message forwarded and enqueuing that message to newly
bound queues)"
- class ExchangeDurabilityField(TwoOptionRadioField):
- def __init__(self, app, name, option1="yes", option2="no"):
- super(ExchangeForm.ExchangeDurabilityField, self).__init__(app, name,
option1, option2)
+ def render_title_1(self, session):
+ return "Initial-Value-Exchange"
- self.option1_title = "Durable"
- self.option2_title = "Transient"
- self.param.default = "no"
+ def render_title_2(self, session):
+ return "No IVE"
+ class ExchangeDurabilityField(TwoOptionRadioField):
def render_title(self, session):
return "Durable?"
def render_field_help(self, session):
return "(Queue is durable)"
+ def render_title_1(self, session):
+ return "Durable"
+
+ def render_title_2(self, session):
+ return "Transient"
+
class ExchangeTypeField(RadioField):
def __init__(self, app, name):
super(ExchangeForm.ExchangeTypeField, self).__init__(app, name, None)
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-11-11 15:57:53 UTC (rev 2783)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-11-11 16:16:53 UTC (rev 2784)
@@ -123,36 +123,6 @@
for coll in Collector.select():
return Pool(coll)
-class AdProperty(object):
- groups = ["Main", "Command Info", "Job Status Info",
"Condor Info", "Other"]
-
- def __init__(self, cls, name):
- self.model = cls.model
- self.cumin_class = cls
-
- self.description = None
- self.example = None
- self.group = "Main"
- self.name = name
- self.renderer = None
- self.title = None
- self.writable = True
-
- self.cumin_class.add_ad_property(self)
-
- def init(self):
- pass
-
- def get_title(self, session):
- if self.title:
- return self.title
- else:
- return self.name
-
- @classmethod
- def get_ad_groups(cls):
- return cls.groups
-
class CuminProperty(object):
def __init__(self, cls, name):
self.model = cls.model
@@ -187,6 +157,33 @@
return value
+class AdProperty(CuminProperty):
+ groups = ["Main", "Command Info", "Job Status Info",
"Condor Info", "Other"]
+
+ def __init__(self, cls, name):
+ # don't call super since we don't want to call add_property
+ self.model = cls.model
+ self.cumin_class = cls
+
+ self.name = name
+ self.title = None
+ self.category = "general"
+ self.summary = False
+ self.escape = True
+ self.prefix = None
+
+ self.description = None
+ self.example = None
+ self.group = "Main"
+ self.renderer = None
+ self.writable = True
+
+ self.cumin_class.add_ad_property(self)
+
+ @classmethod
+ def get_ad_groups(cls):
+ return cls.groups
+
class CuminAction(object):
def __init__(self, cls, name):
self.model = cls.model
@@ -428,8 +425,6 @@
self.ad_properties_by_name = dict()
self.stats = list()
self.actions = list()
- self.ad_properties = list()
- self.ad_properties_by_name = dict()
self.frame = None
@@ -2132,9 +2127,10 @@
prop.title = "Cluster ID"
prop.writable = False
- prop = AdProperty(self, "QDate")
- prop.description = "The number of nanoseconds since epoch when the job was
submitted"
+ prop = self.DateAdProperty(self, "QDate")
+ prop.description = "When the job was submitted"
prop.group = "Other"
+ prop.renderer = prop.render_datetime
prop.title = "QDate"
prop.writable = False
@@ -2230,6 +2226,10 @@
def get_object_name(self, job):
return job.CustomId
+ class DateAdProperty(AdProperty):
+ def render_datetime(self, session, value):
+ return fmt_datetime(value)
+
class JobStatusProperty(AdProperty):
def render_status(self, session, status):
return JobStatusInfo.get_status_string(status)
Modified: mgmt/trunk/cumin/python/cumin/queue.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/queue.py 2008-11-11 15:57:53 UTC (rev 2783)
+++ mgmt/trunk/cumin/python/cumin/queue.py 2008-11-11 16:16:53 UTC (rev 2784)
@@ -393,61 +393,57 @@
return "(File size in pages - 64Kb/page)"
class QueueDurabilityField(TwoOptionRadioField):
- def __init__(self, app, name, option1="durable",
option2="transient"):
- super(QueueForm.QueueDurabilityField, self).__init__(app, name, option1,
option2)
-
- self.option1_title = "Durable"
- self.option2_title = "Transient"
- self.param.default = "transient"
-
def render_title(self, session):
return "Durable?"
def render_field_help(self, session):
return "(Queue is durable)"
- class ClusterDurabilityField(TwoOptionRadioField):
- def __init__(self, app, name, option1="durable",
option2="transient"):
- super(QueueForm.ClusterDurabilityField, self).__init__(app, name, option1,
option2)
+ def render_title_1(self, session):
+ return "Durable"
- self.option1_title = "Cluster Durable"
- self.option2_title = "Not Cluster Durable"
- self.param.default = "transient"
+ def render_title_2(self, session):
+ return "Transient"
+ class ClusterDurabilityField(TwoOptionRadioField):
def render_title(self, session):
return "Cluster Durable?"
def render_field_help(self, session):
return "(Queue becomes durable if there is only one functioning cluster
node)"
- class LVQField(TwoOptionRadioField):
- def __init__(self, app, name, option1="enable",
option2="disable"):
- super(QueueForm.LVQField, self).__init__(app, name, option1, option2)
+ def render_title_1(self, session):
+ return "Cluster Durable"
- self.option1_title = "Enabled"
- self.option2_title = "Not Enabled"
- self.param.default = "disable"
+ def render_title_2(self, session):
+ return "Not Cluster Durable"
+ class LVQField(TwoOptionRadioField):
def render_title(self, session):
return "Enable Last Value Queue?"
def render_field_help(self, session):
return "(Enable LVQ behavior on the queue)"
- class OptimisticField(TwoOptionRadioField):
- def __init__(self, app, name, option1="enable",
option2="disable"):
- super(QueueForm.OptimisticField, self).__init__(app, name, option1, option2)
+ def render_title_1(self, session):
+ return "Enabled"
- self.option1_title = "Enabled"
- self.option2_title = "Not Enabled"
- self.param.default = "disable"
+ def render_title_2(self, session):
+ return "Not Enabled"
+ class OptimisticField(TwoOptionRadioField):
def render_title(self, session):
return "Enable Optimistic Consume?"
def render_field_help(self, session):
return "(Enable optimistic consume on the queue)"
+ def render_title_1(self, session):
+ return "Enabled"
+
+ def render_title_2(self, session):
+ return "Not Enabled"
+
class PolicyField(RadioField):
def __init__(self, app, name):
super(QueueForm.PolicyField, self).__init__(app, name, None)
@@ -531,15 +527,15 @@
# blank one
queue = Queue()
queue.name = queue_name
- queue.durable = (durable == "durable")
+ queue.durable = (durable == "yes")
reg = self.frame.get_object(session)
args = {}
args["reg"] = reg
args["exchange_keys"] = form_binding_info
- args["cluster_durable"] = self.cluster_durable.get(session) ==
"durable"
+ args["cluster_durable"] = self.cluster_durable.get(session) ==
"yes"
args["lvq"] = self.lvq.get(session) == "enable"
- args["optimistic"] = self.optimistic.get(session) ==
"enable"
+ args["optimistic"] = self.optimistic.get(session) ==
"yes"
policy = self.policy.get(session)
if policy == "none":
policy = None
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2008-11-11 15:57:53 UTC (rev 2783)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2008-11-11 16:16:53 UTC (rev 2784)
@@ -1018,11 +1018,11 @@
return "An item with this %s already exists" % self.__field
class TwoOptionRadioField(RadioField):
- def __init__(self, app, name, option1="option1",
option2="option2"):
+ def __init__(self, app, name, option1="yes", option2="no"):
super(TwoOptionRadioField, self).__init__(app, name, None)
self.param = Parameter(app, "param")
- self.param.default = option1
+ self.param.default = option2
self.add_parameter(self.param)
option = self.Option1(app, option1, self.param)
@@ -1031,30 +1031,22 @@
option = self.Option2(app, option2, self.param)
self.add_option(option)
- self.option1_value = option1
- self.option2_value = option2
- self.option1_title = option1
- self.option2_title = option2
-
def render_title(self, session):
return "Pick an option"
+ def render_title_1(self, session):
+ pass
+
+ def render_title_2(self, session):
+ pass
+
class Option1(RadioFieldOption):
- def render_value(self, session):
- return self.parent.option1_value
-
def render_title(self, session):
- return self.parent.option1_title
+ return self.parent.render_title_1(session)
- def render_radio_class(self, session):
- return "class=\"two_options\""
-
class Option2(RadioFieldOption):
- def render_value(self, session):
- return self.parent.option2_value
-
def render_title(self, session):
- return self.parent.option2_title
+ return self.parent.render_title_2(session)
class MultiplicityField(RadioField):
def __init__(self, app, name):