Author: eallen
Date: 2010-04-07 11:00:47 -0400 (Wed, 07 Apr 2010)
New Revision: 3897
Modified:
mgmt/newdata/cumin/python/cumin/stat.py
Log:
Less convoluted way to get RosemaryObject attributes to StatChart
Modified: mgmt/newdata/cumin/python/cumin/stat.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/stat.py 2010-04-07 14:28:04 UTC (rev 3896)
+++ mgmt/newdata/cumin/python/cumin/stat.py 2010-04-07 15:00:47 UTC (rev 3897)
@@ -104,26 +104,15 @@
self.fullpageable = True
- def get_object_id(self, session):
- object = self.object.get(session)
- return object._id
-
- def get_package_name(self, session):
- object = self.object.get(session)
- return object._class._package._name
-
- def get_object_class(self, session):
- object = self.object.get(session)
- return object._class._name
-
def get_href_params(self, session):
+ object = self.object.get(session)
params = list()
- params.append("id=%i" % self.get_object_id(session))
+ params.append("id=%i" % object._id)
params.append("chart_id=%s" % self.render_id(session, None))
params.append("duration=%s" % self.duration.get(session))
- params.append("rpkg=%s" % self.get_package_name(session))
- params.append("rcls=%s" % self.get_object_class(session))
+ params.append("rpkg=%s" % object._class._package._name)
+ params.append("rcls=%s" % object._class._name)
for stat in self.stats:
params.append("stat=%s" % stat)
@@ -151,37 +140,6 @@
cls = object._class
return getattr(cls, self.stats[0]).title
- def render_stats(self, session):
- object = self.object.get(session)
- cls = object._class
-
- writer = Writer()
-
- for name in self.stats:
- stat = getattr(cls, name)
- self.stats_tmpl.render(writer, session, stat)
-
- return writer.to_string()
-
- def render_stat_mode(self, session, stat):
- return self.mode
-
- def render_stat_color(self, session, stat):
- return "rgb(255,0,0)"
-
- def render_stat_value(self, session, stat):
- object = self.object.get(session)
-
- if self.mode == "rate":
- html = stat.rate_html(object)
- else:
- html = stat.value_html(object)
-
- return html
-
- def render_stat_name(self, session, stat):
- return stat.name
-
def render_width(self, session):
return 360
@@ -538,27 +496,27 @@
class ObjectAttribute(Attribute):
def get(self, session):
- rpackage = self.widget.rosemary_package.get(session)
- rclass = self.widget.rosemary_class.get(session)
- rosemary_package = self.app.rosemary._packages_by_name[rpackage]
- rosemary_class = rosemary_package._classes_by_name[rclass]
+ obj = super(FlashFullPage.ObjectAttribute, self).get(session)
+ if not obj:
+ rpackage = self.widget.rosemary_package.get(session)
+ rclass = self.widget.rosemary_class.get(session)
+ rosemary_package = self.app.rosemary._packages_by_name[rpackage]
+ rosemary_class = rosemary_package._classes_by_name[rclass]
- return rosemary_class
+ id = self.widget.id.get(session)
+ conn = self.app.model.get_sql_connection()
+ cursor = conn.cursor()
- class GenericChart(StatFlashChart):
- def render_title(self, session):
- cls = self.object.get(session)
- return getattr(cls, self.stats[0]).title
+ try:
+ obj = rosemary_class.get_object(cursor, id)
+ finally:
+ cursor.close()
- def get_object_id(self, session):
- return self.parent.id.get(session)
-
- def get_package_name(self, session):
- return self.parent.rosemary_package.get(session)
-
- def get_object_class(self, session):
- return self.parent.rosemary_class.get(session)
-
+ self.set(session, obj)
+
+ return obj
+
+ class GenericChart(StatFlashChart):
def render_width(self, session):
return self.parent.container_width.get(session)
Show replies by date