Author: justi9
Date: 2007-10-13 12:46:50 -0400 (Sat, 13 Oct 2007)
New Revision: 1043
Modified:
mgmt/cumin/bin/cumin-test
mgmt/cumin/python/wooly/__init__.py
Log:
Only url decode and encode the value part of url params. Save the
computed param path, since it's called very frequently.
Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test 2007-10-13 15:55:12 UTC (rev 1042)
+++ mgmt/cumin/bin/cumin-test 2007-10-13 16:46:50 UTC (rev 1043)
@@ -75,6 +75,11 @@
stats.sort_stats("cumulative").print_stats(15)
stats.sort_stats("time").print_stats(15)
+ #stats.print_callees("wooly/__init__.*\\(marshal_url_vars\\)")
+ #stats.print_callees("wooly/__init__.*\\(path\\)")
+ #stats.print_callees("wooly/__init__.*\\(get\\)")
+ #stats.print_callees("wooly/__init__.*\\(render\\)")
+
stats.strip_dirs()
else:
try:
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2007-10-13 15:55:12 UTC (rev 1042)
+++ mgmt/cumin/python/wooly/__init__.py 2007-10-13 16:46:50 UTC (rev 1043)
@@ -1,6 +1,6 @@
import sys, os
from cStringIO import StringIO
-from urllib import quote_plus, unquote_plus
+from urllib import quote, unquote
from copy import copy
# XXX use clock instead
from time import time
@@ -177,17 +177,17 @@
self.default = None
self.is_required = True
+ self.cached_path = None
+
def path(self):
- if not self.widget:
- raise Exception("Parameter has no widget")
+ if not self.cached_path:
+ if not self.widget.parent:
+ self.cached_path = self.name
+ else:
+ self.cached_path = self.widget.path() + "." + self.name
- if not self.widget.parent:
- return self.name
- else:
- path = self.widget.path() + "." + self.name
+ return self.cached_path
- return path
-
def set_required(self, is_required):
self.is_required = is_required
@@ -518,10 +518,9 @@
default = param.get_default(self)
if value not in (default, None):
- skey = quote_plus(key)
- svalue = quote_plus(param.marshal(value))
+ svalue = quote(param.marshal(value))
- vars.append("%s=%s" % (skey, svalue))
+ vars.append("%s=%s" % (key, svalue))
return separator.join(vars)
@@ -546,11 +545,9 @@
for var in vars:
try:
- skey, svalue = var.split("=")
+ key, svalue = var.split("=")
+ value = unquote(svalue)
- key = unquote_plus(skey)
- value = unquote_plus(svalue)
-
param = self.app.get_parameter(key)
if param: