[rhmessaging-commits] rhmessaging commits: r1770 - in mgmt/cumin/python: wooly and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Mar 7 11:53:30 EST 2008


Author: justi9
Date: 2008-03-07 11:53:30 -0500 (Fri, 07 Mar 2008)
New Revision: 1770

Modified:
   mgmt/cumin/python/cumin/broker.py
   mgmt/cumin/python/cumin/broker.strings
   mgmt/cumin/python/cumin/brokergroup.py
   mgmt/cumin/python/cumin/brokergroup.strings
   mgmt/cumin/python/cumin/queue.py
   mgmt/cumin/python/cumin/widgets.py
   mgmt/cumin/python/wooly/forms.py
   mgmt/cumin/python/wooly/forms.strings
Log:
Convert the single object forms to use fields and field forms.  As a
result, we can remove some duplicate html.

Make input item sets produce html lists of inputs.



Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py	2008-03-07 04:59:23 UTC (rev 1769)
+++ mgmt/cumin/python/cumin/broker.py	2008-03-07 16:53:30 UTC (rev 1770)
@@ -596,37 +596,31 @@
 
         return not len(nerrs) and not len(aerrs)
 
-class BrokerEdit(CuminForm, Frame):
+class BrokerEdit(CuminFieldForm):
     def __init__(self, app, name):
         super(BrokerEdit, self).__init__(app, name)
 
-        self.broker_name = TextInput(app, "name", self)
-        self.add_child(self.broker_name)
+        self.broker_name = NameField(app, "name", self)
+        self.add_field(self.broker_name)
 
-        self.groups = BrokerGroupInputSet(app, "groups", self)
-        self.add_child(self.groups)
+        self.groups = BrokerGroupCheckboxField(app, "groups", self)
+        self.add_field(self.groups)
         
     def get_title(self, session, reg):
         return "Edit Broker '%s'" % reg.name
 
-    def validate(self, session):
-        error = None
-
-        name = self.broker_name.get(session)
-
-        if name == "":
-            error = EmptyInputError(self.broker_name)
-            self.broker_name.add_error(session, error)
-        
-        return error is None
-
     def process_cancel(self, session, reg):
         branch = session.branch()
-        self.frame().show_view(branch)
+        self.page().pop_current_frame(branch)
+        self.page().get_current_frame(branch).show_view(branch)
         self.page().set_redirect_url(session, branch.marshal())
 
     def process_submit(self, session, reg):
-        if self.validate(session):
+        errors = self.validate(session)
+
+        if errors:
+            pass
+        else:
             action = self.app.model.broker_registration.edit
             args = {"name": self.broker_name.get(session)}
             action.invoke(reg, args)
@@ -692,4 +686,4 @@
     def render_item_content(self, session, id):
         return "Unregister Broker '%s'" % BrokerRegistration.get(id).name
 
-from brokergroup import BrokerGroupInputSet
+from brokergroup import BrokerGroupCheckboxField

Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings	2008-03-07 04:59:23 UTC (rev 1769)
+++ mgmt/cumin/python/cumin/broker.strings	2008-03-07 16:53:30 UTC (rev 1770)
@@ -202,34 +202,6 @@
 [BrokerSetForm.group_html]
 <option value="{group_value}" {group_selected_attr}>{group_name}</option>
 
-[BrokerEdit.html]
-<form id="{id}" class="mform" method="post" action="?">
-  <div class="head">
-    <h1>{title}</h1>
-  </div>
-  <div class="body">
-    <span class="legend">Name</span>
-    <fieldset>{name}</fieldset>
-
-    <span class="legend">Groups</span>
-    <fieldset>{groups}</fieldset>
-
-    {hidden_inputs}
-  </div>
-  <div class="foot">
-    <a class="help action" href="{href}" target="help">Help</a>
-    {submit}
-    {cancel}
-  </div>
-</form>
-<script defer="defer">
-(function() {
-    var elem = wooly.doc().elembyid("{id}").node.elements[1];
-    elem.focus();
-    elem.select();
-}())
-</script>
-
 [BrokerGroupInputSet.item_html]
 <div class="field">
   <input type="checkbox" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr}/>

Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py	2008-03-07 04:59:23 UTC (rev 1769)
+++ mgmt/cumin/python/cumin/brokergroup.py	2008-03-07 16:53:30 UTC (rev 1770)
@@ -59,6 +59,18 @@
     def render_item_checked_attr(self, session, group):
         return group in self.param.get(session) and "checked=\"checked\""
 
+class BrokerGroupCheckboxField(FormField):
+    def __init__(self, app, name, form):
+        super(BrokerGroupCheckboxField, self).__init__(app, name, form)
+
+        self.__inputs = BrokerGroupInputSet(app, "inputs", form)
+        self.add_child(self.__inputs)
+
+        self.set_parameter(self.__inputs.get_parameter())
+
+    def get_title(self, session, object):
+        return "Broker Groups"
+
 class BrokerGroupFrame(CuminFrame):
     def __init__(self, app, name):
         super(BrokerGroupFrame, self).__init__(app, name)
@@ -125,12 +137,12 @@
 
             return "where exists (%s)" % subquery
 
-class BrokerGroupForm(CuminForm, Frame):
+class BrokerGroupForm(CuminFieldForm):
     def __init__(self, app, name):
         super(BrokerGroupForm, self).__init__(app, name)
 
-        self.group_name = TextInput(app, "name", self)
-        self.add_child(self.group_name)
+        self.group_name = NameField(app, "name", self)
+        self.add_field(self.group_name)
 
 class BrokerGroupAdd(BrokerGroupForm):
     def get_title(self, session, model):
@@ -138,35 +150,45 @@
 
     def process_cancel(self, session, model):
         branch = session.branch()
-        self.frame().frame().show_view(branch)
         self.page().pop_current_frame(branch)
         self.page().pop_current_frame(branch)
+        self.page().get_current_frame(branch).show_view(branch)
         self.page().set_redirect_url(session, branch.marshal())
     
     def process_submit(self, session, model):
-        args = {"name": self.group_name.get(session)}
-        method = self.app.model.broker_group.add
-        method.invoke(None, args)
+        errors = self.validate(session)
 
-        self.process_cancel(session, model)
+        if errors:
+            pass
+        else:
+            args = {"name": self.group_name.get(session)}
+            method = self.app.model.broker_group.add
+            method.invoke(None, args)
 
+            self.process_cancel(session, model)
+
 class BrokerGroupEdit(BrokerGroupForm):
     def get_title(self, session, group):
         return "Edit Group '%s'" % group.name
 
     def process_cancel(self, session, group):
         branch = session.branch()
-        self.frame().show_view(branch)
         self.page().pop_current_frame(branch)
+        self.page().get_current_frame(branch).show_view(branch)
         self.page().set_redirect_url(session, branch.marshal())
 
     def process_submit(self, session, group):
-        args = {"name": self.group_name.get(session)}
-        method = self.app.model.broker_group.edit
-        method.invoke(group, args)
+        errors = self.validate(session)
 
-        self.process_cancel(session, group)
+        if errors:
+            pass
+        else:
+            args = {"name": self.group_name.get(session)}
+            method = self.app.model.broker_group.edit
+            method.invoke(group, args)
 
+            self.process_cancel(session, group)
+
     def process_display(self, session, group):
         self.group_name.set(session, group.name)
 

Modified: mgmt/cumin/python/cumin/brokergroup.strings
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.strings	2008-03-07 04:59:23 UTC (rev 1769)
+++ mgmt/cumin/python/cumin/brokergroup.strings	2008-03-07 16:53:30 UTC (rev 1770)
@@ -42,28 +42,3 @@
 </table>
 
 {tabs}
-
-[BrokerGroupForm.html]
-<form id="{id}" class="mform" method="post" action="?">
-  <div class="head">
-    <h1>{title}</h1>
-  </div>
-  <div class="body">
-    <span class="legend">Name</span>
-    <fieldset>{name}</fieldset>
-
-    {hidden_inputs}
-  </div>
-  <div class="foot">
-    <a class="help action" href="{href}" target="help">Help</a>
-    {submit}
-    {cancel}
-  </div>
-</form>
-<script defer="defer">
-(function() {
-    var elem = wooly.doc().elembyid("{id}").node.elements[1];
-    elem.focus();
-    elem.select();
-}())
-</script>

Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py	2008-03-07 04:59:23 UTC (rev 1769)
+++ mgmt/cumin/python/cumin/queue.py	2008-03-07 16:53:30 UTC (rev 1770)
@@ -298,7 +298,7 @@
     def render_item_name(self, session, binding):
         return binding.exchange.name or "<em>Default</em>"
 
-class QueueForm(CuminFieldForm, Frame):
+class QueueForm(CuminFieldForm):
     def __init__(self, app, name):
         super(QueueForm, self).__init__(app, name)
 
@@ -309,6 +309,13 @@
         self.add_field(self.durable)
 
 class QueueAdd(QueueForm):
+    def process_cancel(self, session, object):
+        branch = session.branch()
+        self.page().pop_current_frame(branch)
+        self.page().pop_current_frame(branch)
+        self.page().get_current_frame(branch).show_view(branch)
+        self.page().set_redirect_url(session, branch.marshal())
+
     def process_submit(self, session, object):
         errors = self.validate(session)
 
@@ -323,11 +330,7 @@
 
             print "XXX add queue", name, self.durable.get(session)
             
-            branch = session.branch()
-            #self.frame().frame().show_queue(branch, queue).show_view(branch)
-            self.page().pop_current_frame(branch)
-            self.page().pop_current_frame(branch).show_view(branch)
-            self.page().set_redirect_url(session, branch.marshal())
+            self.process_cancel(session, object)
 
     def get_title(self, session, object):
         reg = self.frame().frame().get_object(session, None)

Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py	2008-03-07 04:59:23 UTC (rev 1769)
+++ mgmt/cumin/python/cumin/widgets.py	2008-03-07 16:53:30 UTC (rev 1770)
@@ -149,7 +149,7 @@
         def render_content(self, session, object):
             return self.parent.render_submit_content(session, object)
 
-class CuminFieldForm(CuminForm, FieldForm):
+class CuminFieldForm(CuminForm, FieldForm, Frame):
     pass
 
 class CuminConfirmForm(CuminForm):

Modified: mgmt/cumin/python/wooly/forms.py
===================================================================
--- mgmt/cumin/python/wooly/forms.py	2008-03-07 04:59:23 UTC (rev 1769)
+++ mgmt/cumin/python/wooly/forms.py	2008-03-07 16:53:30 UTC (rev 1770)
@@ -307,7 +307,7 @@
         self.__input = input
         return input
 
-    def render_content(self, session, object):
+    def render_inputs(self, session, object):
         return self.__input.render(session, object)
 
 class StringField(ScalarField):
@@ -339,7 +339,7 @@
         self.options.append(option)
         self.add_child(option)
 
-    def render_content(self, session, object):
+    def render_inputs(self, session, object):
         writer = Writer()
 
         for option in self.options:

Modified: mgmt/cumin/python/wooly/forms.strings
===================================================================
--- mgmt/cumin/python/wooly/forms.strings	2008-03-07 04:59:23 UTC (rev 1769)
+++ mgmt/cumin/python/wooly/forms.strings	2008-03-07 16:53:30 UTC (rev 1770)
@@ -11,18 +11,22 @@
 <input type="radio" name="{name}" value="{value}" tabindex="{tab_index}" {checked_attr} {disabled_attr}/>
 
 [CheckboxInputSet.html]
-{items}
+<ul>{items}</ul>
 
 [CheckboxInputSet.item_html]
-<input type="checkbox" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
-{item_content}
+<li>
+  <input type="checkbox" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
+  {item_content}
+</li>
 
 [RadioInputSet.html]
-{items}
+<ul>{items}</ul>
 
 [RadioInputSet.item_html]
-<input type="radio" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
-{item_content}
+<li>
+  <input type="radio" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
+  {item_content}
+</li>
 
 [OptionInputSet.html]
 <select name="{name}" tabindex="{tab_index}" {disabled_attr}>{items}</select>
@@ -47,7 +51,7 @@
   margin: 0 0 1em 0;
 }
 
-div.field div.content {
+div.field div.inputs {
   margin: 0 0 1em 1em;
 }
 
@@ -55,7 +59,7 @@
 <div class="field">
   <div class="title">{title}</div>
   {errors}
-  <div class="content">{content}</div>
+  <div class="inputs">{inputs}</div>
 </div>
 
 [FormFieldErrors.html]




More information about the rhmessaging-commits mailing list