moksha/api/widgets/containers/templates/dashboardcontainer.mak | 4
moksha/lib/helpers.py | 53 ++++++++--
moksha/public/javascript/moksha.js | 23 +++-
3 files changed, 67 insertions(+), 13 deletions(-)
New commits:
commit 0571e9b586f5e77b72ea50115b2236e3e89803c7
Merge: ae0e089... c4f7802...
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 21 22:29:38 2009 -0400
Merge branch 'master' of git+ssh://johnp@git.fedorahosted.org/git/moksha
commit ae0e0893d6a5b92d3d11e98c9bb81aa0c9403664
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 21 22:28:15 2009 -0400
fix handling and checking of multiple query key values
diff --git a/moksha/api/widgets/containers/templates/dashboardcontainer.mak
b/moksha/api/widgets/containers/templates/dashboardcontainer.mak
index a9042da..d55435d 100644
--- a/moksha/api/widgets/containers/templates/dashboardcontainer.mak
+++ b/moksha/api/widgets/containers/templates/dashboardcontainer.mak
@@ -4,8 +4,4 @@
${applist_widget(category=c)}
% endfor
</div>
-
- <div id="overlay">
- <div id="preloader"><img
src="/toscawidgets/resources/moksha.widgets.layout.layout/static/loader.gif"
alt="" /></div>
- </div>
</div>
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py
index 01cc726..2abe9ca 100644
--- a/moksha/lib/helpers.py
+++ b/moksha/lib/helpers.py
@@ -43,8 +43,7 @@ def _update_params(params, d):
value = _update_params(value, d)
value = json.dumps(value)
elif isinstance(value, list):
- # FIXME: This should be recursive
- value = json.dumps(value)
+ value = value
if value != None:
p[k] = value
@@ -273,14 +272,23 @@ class App(ConfigWrapper):
def _create_query_string(self, params):
qlist = []
for k, i in params.iteritems():
- s = str(i)
- s = urllib.quote_plus(s)
+ if isinstance(i, (list, tuple)):
+ # break out lists into multiple entries of the same key
+ for j in i:
+ s = str(j)
+ s = urllib.quote_plus(s)
+ qlist.append("%s=%s" % (k, s))
+
+ else:
+ s = str(i)
+ s = urllib.quote_plus(s)
- qlist.append("%s=%s" % (k, s))
+ qlist.append("%s=%s" % (k, s))
result = ""
if qlist:
result = '?' + '&'.join(qlist)
+
return result
def process(self, d=None):
@@ -491,12 +499,43 @@ class MokshaWidget(Widget):
auth=auth,
css_class=css_class)
+class param_contains(Predicate):
+ """
+ Checks the parameters of the environment and return True if the
+ parameter contains the value specified. If the parameter is a list
+ (more than one value) then check each item in the list.
+ Note this is the environment params (query string and post file) not the TG
+ or ToscaWidget param dicts
+ """
+ message = u'Parameter "%(param)s" is does not contain value
"%(value)s"'
+
+ def __init__(self, param, value, **kwargs):
+ super(param_contains, self).__init__(**kwargs)
+ self.param = param
+ self.value = value
+
+ def evaluate(self, environ, credentials):
+ req = Request(environ)
+ p = req.params.getall(self.param)
+
+ if not p:
+ return self.unmet(param = self.param, value = self.value)
+
+ print p
+ for v in p:
+ print v, '==', self.value
+ if v == self.value:
+ return
+
+ return self.unmet(param = self.param, value = self.value)
+
class param_has_value(Predicate):
"""
Checks the parameters of the environment and return True if the
- parameter specified holds a value
+ parameter specified holds a value. Note this is the environment params
+ (query string and post file) not the TG or ToscaWidget param dicts
"""
- message = u'Parameter "%s(param)" is not set'
+ message = u'Parameter "%(param)s" is not set'
def __init__(self, param, empty_str_is_valid = False, **kwargs):
super(param_has_value, self).__init__(**kwargs)
diff --git a/moksha/public/javascript/moksha.js b/moksha/public/javascript/moksha.js
index 0cd73d8..eaeca92 100644
--- a/moksha/public/javascript/moksha.js
+++ b/moksha/public/javascript/moksha.js
@@ -276,7 +276,15 @@ moksha = {
var qlist = []
for (q in this.queryKey) {
- qlist.push(q + '=' + this.queryKey[q]);
+ var value = this.queryKey[q]
+ if (typeof(value) == 'string') {
+ qlist.push(q + '=' + value);
+ } else {
+ // must be a list, break up into seperate query elements
+ for (i in value) {
+ qlist.push(q + '=' + value[i]);
+ }
+ }
}
var query = qlist.join('&')
@@ -298,7 +306,18 @@ moksha = {
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
- if ($1) uri[o.q.name][$1] = $2;
+ if ($1) {
+ var value = uri[o.q.name][$1];
+ if (value) {
+ if (typeof(value) === 'string')
+ value = [value];
+
+ value.push($2);
+ uri[o.q.name][$1] = value;
+ } else {
+ uri[o.q.name][$1] = $2;
+ }
+ }
});
return uri;
Show replies by date