moksha/connector/connector.py | 2 +-
moksha/middleware/connector.py | 32 ++++++++++++++++++--------------
2 files changed, 19 insertions(+), 15 deletions(-)
New commits:
commit 7f6c0a5e164f68b2b17d9215d81267abe1861c0c
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 13 15:14:29 2009 -0400
fix up some issues with calling connector methods without extra path info
diff --git a/moksha/connector/connector.py b/moksha/connector/connector.py
index e06ddd2..8d45e6f 100644
--- a/moksha/connector/connector.py
+++ b/moksha/connector/connector.py
@@ -81,7 +81,7 @@ class IConnector(object):
if op in ('request_data', 'call', 'query',
'query_model'):
return getattr(self, op)(resource_path, params, _cookies, **kwds)
elif op in self._method_paths:
- _method_paths[op](params, resource_path, _cookies, **kwds)
+ self._method_paths[op](self, resource_path, params, _cookies, **kwds)
return None
diff --git a/moksha/middleware/connector.py b/moksha/middleware/connector.py
index 4b5bbc2..eca14b2 100644
--- a/moksha/middleware/connector.py
+++ b/moksha/middleware/connector.py
@@ -85,24 +85,28 @@ class MokshaConnectorMiddleware(object):
# check last part of path to see if it is json data
dispatch_params = {};
- p = urllib.unquote_plus(path[-1].lstrip())
- if p.startswith('{'):
- dp = json.loads(p)
+ if len(path) > 0:
+ p = urllib.unquote_plus(path[-1].lstrip())
+ if p.startswith('{'):
+ dp = json.loads(p)
- f = dp.get('filters')
- if isinstance(f, basestring):
- dp['filters'] = json.loads(f)
- path = path[:-1]
+ f = dp.get('filters')
+ if isinstance(f, basestring):
+ dp['filters'] = json.loads(f)
+ path = path[:-1]
- # scrub dispatch_params keys of unicode so we can pass as keywords
- for (k, v) in dp.iteritems():
- dispatch_params[str(k)] = v
+ # scrub dispatch_params keys of unicode so we can pass as keywords
+ for (k, v) in dp.iteritems():
+ dispatch_params[str(k)] = v
- # prevent trailing slash
- if not p:
- path = path[:-1]
+ # prevent trailing slash
+ if not p:
+ path = path[:-1]
+
+ path = '/'.join(path)
+ else:
+ path = ''
- path = '/'.join(path)
conn = self._connectors.get(conn)
# pretty print output
Show replies by date