[rhmessaging-commits] rhmessaging commits: r1821 - mgmt/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Apr 1 13:11:41 EDT 2008


Author: justi9
Date: 2008-04-01 13:11:41 -0400 (Tue, 01 Apr 2008)
New Revision: 1821

Modified:
   mgmt/cumin/python/cumin/model.py
   mgmt/cumin/python/cumin/widgets.py
Log:
Add categories and a get_title method to CuminProperty.

Add all system properties to CuminSystem.



Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py	2008-04-01 15:50:22 UTC (rev 1820)
+++ mgmt/cumin/python/cumin/model.py	2008-04-01 17:11:41 UTC (rev 1821)
@@ -83,12 +83,28 @@
         self.model = cls.model
         self.cumin_class = cls
         self.name = name
+        self.title = None
+        self.categories = ()
 
         self.cumin_class.add_property(self)
 
-    def get(self, object):
-        return getattr(object, self.name, None)
+    def get_title(self, session):
+        if self.title:
+            return self.title
+        else:
+            return self.name
 
+    def value(self, object):
+        value = getattr(object, self.name, None)
+
+        if isinstance(value, datetime):
+            value = fmt_datetime(value)
+
+        if value is None:
+            value = fmt_none()
+
+        return value
+
 class CuminAction(object):
     def __init__(self, cls, name):
         self.model = cls.model
@@ -270,11 +286,22 @@
         self.stats = list()
         self.actions = list()
 
-        CuminProperty(self, "idOriginal")
-        CuminProperty(self, "recTime")
-        CuminProperty(self, "creationTime")
-        CuminProperty(self, "deletionTime")
+        prop = CuminProperty(self, "idOriginal")
+        prop.title = "Management ID"
+        prop.categories = ("basic",)
 
+        prop = CuminProperty(self, "creationTime")
+        prop.title = "Creation Time"
+        prop.categories = ("basic",)
+
+        prop = CuminProperty(self, "deletionTime")
+        prop.title = "Deletion Time"
+        prop.categories = ("basic",)
+
+        prop = CuminProperty(self, "recTime")
+        prop.title = "Last Updated"
+        prop.categories = ("basic",)
+
         self.Add(self, "add")
         self.Edit(self, "edit")
         self.Remove(self, "remove")
@@ -372,6 +399,24 @@
     def __init__(self, model):
         super(CuminSystem, self).__init__(model, "system", System, SystemStats)
 
+        prop = CuminProperty(self, "sysId")
+        prop.title = "System ID"
+        
+        prop = CuminProperty(self, "nodeName")
+        prop.title = "Address"
+
+        prop = CuminProperty(self, "osName")
+        prop.title = "Kernel"
+
+        prop = CuminProperty(self, "release")
+        prop.title = "Kernel Release"
+
+        prop = CuminProperty(self, "version")
+        prop.title = "Kernel Version"
+
+        prop = CuminProperty(self, "machine")
+        prop.title = "Architecture"
+
 class CuminBroker(CuminClass):
     def __init__(self, model):
         super(CuminBroker, self).__init__(model, "broker", Broker, BrokerStats)

Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py	2008-04-01 15:50:22 UTC (rev 1820)
+++ mgmt/cumin/python/cumin/widgets.py	2008-04-01 17:11:41 UTC (rev 1821)
@@ -231,6 +231,15 @@
         return "%i error%s, %i warning%s" % \
                (error_count, ess(error_count),
                 warning_count, ess(warning_count))
+
+class CuminProperties(PropertySet):
+    def get_args(self, session):
+        return self.frame.get_args(session)
+
+    def do_get_items(self, session, object):
+        cls = self.app.model.get_class_by_object(object)
+        return [(x.get_title(session), x.value(object))
+                for x in cls.properties]
     
 class StateSwitch(ItemSet):
     def __init__(self, app, name):




More information about the rhmessaging-commits mailing list