Author: justi9
Date: 2007-10-13 10:53:01 -0400 (Sat, 13 Oct 2007)
New Revision: 1040
Modified:
mgmt/cumin/python/wooly/__init__.py
Log:
Takes care of hotspot that showed up in profiling. Stores the result of calculating the
parameters in scope for a frame instead of recalculating it on each session.marshal.
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2007-10-13 14:17:34 UTC (rev 1039)
+++ mgmt/cumin/python/wooly/__init__.py 2007-10-13 14:53:01 UTC (rev 1040)
@@ -99,12 +99,17 @@
if str:
return str
- def save_parameters(self, session):
- session.save_parameters(self.parameters)
+ def get_saved_parameters(self, session):
+ params = list()
+ params.extend(self.parameters)
for child in self.children:
- child.save_parameters(session)
+ cparams = child.get_saved_parameters(session)
+ if cparams:
+ params.extend(cparams)
+ return params
+
def process(self, session, object):
if session.debug:
call = WidgetCall(session.debug.process_stack,
@@ -254,6 +259,8 @@
self.frame = self.FrameParameter(app, "frame")
self.add_parameter(self.frame)
+ self.cached_parameters = dict()
+
def get_last_modified(self, session):
return datetime.utcnow()
@@ -271,6 +278,18 @@
def get_frame(self, session):
return self.frame.get(session)
+ def get_saved_parameters(self, session):
+ frame = self.get_frame(session)
+
+ if frame:
+ if frame not in self.cached_parameters:
+ params = super(Page, self).get_saved_parameters(session)
+ self.cached_parameters[frame] = params
+
+ return self.cached_parameters[frame]
+ else:
+ return super(Page, self).get_saved_parameters(session)
+
class FrameParameter(Parameter):
def do_marshal(self, frame):
return frame.path()
@@ -291,11 +310,11 @@
if self.object:
return self.object.get(session)
- def save_parameters(self, session):
+ def get_saved_parameters(self, session):
frame = self.page().get_frame(session)
if not frame or self is frame or self in frame.ancestors():
- super(Frame, self).save_parameters(session)
+ return super(Frame, self).get_saved_parameters(session)
def do_process(self, session, object):
new_object = self.get_object(session)
@@ -466,7 +485,7 @@
self.redirect = redirect
def save_parameters(self, params):
- self.saved_parameters += params
+ self.saved_parameters.extend(params)
def marshal(self):
url = self.marshal_page() + "?" + self.marshal_url_vars()
@@ -480,11 +499,10 @@
return self.get_page().name
def marshal_url_vars(self, separator=";"):
- self.get_page().save_parameters(self)
-
+ params = self.get_page().get_saved_parameters(self)
vars = list()
- for param in self.saved_parameters:
+ for param in params:
key = param.path()
value = self.get(key)
default = param.get_default(self)
@@ -514,8 +532,6 @@
self.set_page(self.app.get_page(string))
def unmarshal_url_vars(self, string, separator=";"):
- self.get_page().save_parameters(self)
-
vars = string.split(separator)
for var in vars:
Show replies by date