[rhmessaging-commits] rhmessaging commits: r2762 - mgmt/trunk/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Nov 6 16:38:32 EST 2008


Author: eallen
Date: 2008-11-06 16:38:32 -0500 (Thu, 06 Nov 2008)
New Revision: 2762

Modified:
   mgmt/trunk/cumin/python/cumin/exchange.py
   mgmt/trunk/cumin/python/cumin/exchange.strings
   mgmt/trunk/cumin/python/cumin/model.py
Log:
Added new options on Add Exchange form

Modified: mgmt/trunk/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/exchange.py	2008-11-06 19:33:49 UTC (rev 2761)
+++ mgmt/trunk/cumin/python/cumin/exchange.py	2008-11-06 21:38:32 UTC (rev 2762)
@@ -343,40 +343,127 @@
         self.exchange_name = ExchangeNameField(app, "exchange_name")
         self.add_field(self.exchange_name)
  
-        self.type = Parameter(app, "type")
-        self.type.default = "direct"
-        self.add_parameter(self.type)
+        self.exchange_type = self.ExchangeTypeField(app, "exchange_type")
+        self.add_field(self.exchange_type)
+        
+        self.durable = self.ExchangeDurabilityField(app, "durable")
+        self.add_field(self.durable)
+        
+        self.more = MoreFieldSet(app, "more")
+        self.add_field(self.more)
+        
+        self.sequence = self.SequenceField(app, "sequence")
+        self.more.add_field(self.sequence)
+        
+        self.ive = self.IVEField(app, "ive")
+        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.direct = RadioInput(app, "direct", self.type)
-        self.add_child(self.direct)
+            self.option1_title = "Insert Sequence"
+            self.option2_title = "No Sequence"
+            self.param.default = "no"
 
-        self.topic = RadioInput(app, "topic", self.type)
-        self.add_child(self.topic)
+        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)"
 
-        self.fanout = RadioInput(app, "fanout", self.type)
-        self.add_child(self.fanout)
+    class IVEField(TwoOptionRadioField):
+        def __init__(self, app, name, option1="yes", option2="no"):
+            super(ExchangeForm.IVEField, self).__init__(app, name, option1, option2)
+
+            self.option1_title = "Initial-Value-Exchange"
+            self.option2_title = "No IVE"
+            self.param.default = "no"
+
+        def render_title(self, session):
+            return "Initial Value Exchange?"
         
-        self.headers = RadioInput(app, "headers", self.type)
-        self.add_child(self.headers)
+        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)
+
+            self.option1_title = "Durable"
+            self.option2_title = "Transient"
+            self.param.default = "no"
+
+        def render_title(self, session):
+            return "Durable?"
         
-        self.xml = RadioInput(app, "xml", self.type)
-        self.add_child(self.xml)
-        
-    def render_direct_id(self, session, *args):
-        return self.direct.path
+        def render_field_help(self, session):
+            return "(Queue is durable)"
+
+    class ExchangeTypeField(RadioField):
+        def __init__(self, app, name):
+            super(ExchangeForm.ExchangeTypeField, self).__init__(app, name, None)
     
-    def render_topic_id(self, session, *args):
-        return self.topic.path
+            self.param = Parameter(app, "param")
+            self.param.default = "direct"
+            self.add_parameter(self.param)
     
-    def render_fanout_id(self, session, *args):
-        return self.fanout.path
+            option = self.Direct(app, "direct", self.param)
+            self.add_option(option)
 
-    def render_headers_id(self, session, *args):
-        return self.headers.path
+            option = self.Topic(app, "topic", self.param)
+            self.add_option(option)
     
-    def render_xml_id(self, session, *args):
-        return self.xml.path
-
+            option = self.Fanout(app, "fanout", self.param)
+            self.add_option(option)
+            
+            option = self.Headers(app, "headers", self.param)
+            self.add_option(option)
+            
+            option = self.XML(app, "xml", self.param)
+            self.add_option(option)
+        
+        def render_title(self, session):
+            return "Exchange Type"
+    
+        def render_field_help(self, session):
+            return "(Type of exchange to add)"
+            
+        class Direct(RadioFieldOption):
+            def render_value(self, session):
+                return "direct"
+    
+            def render_title(self, session):
+                return "<em>Direct:</em> Route messages to queues by queue name"
+    
+        class Topic(RadioFieldOption):
+            def render_value(self, session):
+                return "topic"
+    
+            def render_title(self, session):
+                return "<em>Topic:</em> Route messages to queues by topic keyword match"
+    
+        class Fanout(RadioFieldOption):
+            def render_value(self, session):
+                return "fanout"
+    
+            def render_title(self, session):
+                return "<em>Fan Out:</em> Route message to all queues attached to this exchange"
+    
+        class Headers(RadioFieldOption):
+            def render_value(self, session):
+                return "headers"
+    
+            def render_title(self, session):
+                return "<em>Headers:</em> Route message to queues based on content of the message header"
+    
+        class XML(RadioFieldOption):
+            def render_value(self, session):
+                return "xml"
+    
+            def render_title(self, session):
+                return "<em>XML:</em> Route message to queues based on XML content of the message"
+    
 class ExchangeAdd(ExchangeForm):
     def get_args(self, session):
         return self.frame.frame.get_args(session)
@@ -395,10 +482,15 @@
             reg = self.frame.get_object(session)
             exchange = Exchange()
             exchange.name = self.exchange_name.get(session)
-            exchange.type = self.type.get(session)
+            exchange.type = self.exchange_type.get(session)
+            exchange.durable = self.durable.get(session) == "yes" 
+            args = {}
+            args["reg"] = reg
+            args["sequence"] = self.sequence.get(session) == "yes"
+            args["ive"] = self.ive.get(session) == "yes"
             
             action = self.app.model.broker.add_exchange
-            action.invoke(exchange, reg)
+            action.invoke(exchange, args)
 
             self.process_cancel(session)
             

Modified: mgmt/trunk/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/exchange.strings	2008-11-06 19:33:49 UTC (rev 2761)
+++ mgmt/trunk/cumin/python/cumin/exchange.strings	2008-11-06 21:38:32 UTC (rev 2762)
@@ -79,59 +79,6 @@
 [ExchangeSet.item_html]
 <tr>{cells}</tr>
 
-[ExchangeForm.html]
-<form id="{id}" class="ExchangeForm mform" method="post" action="?">
-  <div class="head">
-    <h1>{title}</h1>
-  </div>
-  <div class="body">
-      <div class="field">{exchange_name}</div>
-
-    <div style="clear:right;">
-    <span class="legend">Type</span>
-    <fieldset>
-      <div class="field">
-        {direct}
-        <label for="{direct_id}"><em>Direct:</em> Route messages to queues by queue name</label>
-      </div>
-      <div class="field">
-        {topic}
-        <label for="{topic_id}"><em>Topic:</em> Route messages to queues by topic keyword match</label>
-      </div>
-      <div class="field">
-        {fanout}
-        <label for="{fanout_id}"><em>Fan Out:</em> Route message to all queues attached to this exchange</label>
-      </div>
-      <div class="field">
-        {headers}
-        <label for="{headers_id}"><em>Headers:</em> Route message to queues based on content of the message header</label>
-      </div>
-      <div class="field">
-        {xml}
-        <label for="{xml_id}"><em>XML:</em> Route message to queues based on XML content of the message</label>
-      </div>
-    </fieldset>
-	</div>
-	
-    {hidden_inputs}
-  </div>
-  <div class="foot">
-    {help}
-    {submit}
-    {cancel}
-  </div>
-</form>
-<script type="text/javascript" defer="defer">
-<![CDATA[
-(function() {
-    // elements[0] is a fieldset, at least in firefox
-    var elem = wooly.doc().elembyid("{id}").node.elements[0];
-    elem.focus();
-    elem.select();
-}())
-]]>
-</script>
-
 [ExchangeStatus.javascript]
 function updateExchangeStatus(id, exchange) {
     updateStatus(id, exchange);

Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py	2008-11-06 19:33:49 UTC (rev 2761)
+++ mgmt/trunk/cumin/python/cumin/model.py	2008-11-06 21:38:32 UTC (rev 2762)
@@ -723,7 +723,7 @@
 
         prop = CuminProperty(self, "dataDir")
         prop.title = "Data Directory"
-
+        
         action = self.AddExchange(self, "add_exchange")
         action.summary = True
 
@@ -747,6 +747,9 @@
         return broker.id
 
     class AddExchange(CuminAction):
+        MSG_SEQUENCE = "qpid.msg_sequence"
+        IVE = "qpid.ive"
+
         def get_title(self, session):
             return "Add Exchange"
 
@@ -757,10 +760,20 @@
             frame = self.cumin_class.show_object(session, reg)
             return frame.exchange_add.show(session)
         
-        def do_invoke(self, exchange, reg, completion):
+        def do_invoke(self, exchange, args, completion):
+
+            reg = args["reg"]
+            declArgs = {}
+            if args["sequence"]:
+                declArgs[self.MSG_SEQUENCE] = 1
+            if args["ive"]:
+                declArgs[self.IVE] = 1
+            
             session = self.getSessionFromRegistration(reg)
             session.exchange_declare(exchange=exchange.name, 
-                                          type=exchange.type)
+                                     type=exchange.type, 
+                                     durable=exchange.durable, 
+                                     arguments=declArgs)
             # if the above call fails, an exception is
             # raised and we won't get here
             completion("OK")
@@ -1119,6 +1132,15 @@
         prop.title = "Type"
         prop.summary = True
 
+        prop = CuminProperty(self, "durable")
+        prop.title = "Durable?"
+        prop.summary = True
+
+        prop = CuminProperty(self, "arguments")
+        prop.title = "Arguments"
+        prop.prefix = "qpid."
+        prop.escape = False
+
         stat = CuminStat(self, "producerCount")
         stat.title = "Producers"
         stat.unit = "producer"




More information about the rhmessaging-commits mailing list