moksha/controllers/root.py | 12 +++++++++--- moksha/lib/helpers.py | 2 +- moksha/middleware/connector.py | 4 +++- moksha/wsgiapp.py | 8 +++++--- 4 files changed, 18 insertions(+), 8 deletions(-)
New commits: commit dae26624a9ab0f2f4647b2315610859ca9526a92 Author: Luke Macken lmacken@redhat.com Date: Sun Mar 22 10:49:13 2009 -0400
Fix some string handling in our connector middleware
diff --git a/moksha/middleware/connector.py b/moksha/middleware/connector.py index b69c2f9..8b66209 100644 --- a/moksha/middleware/connector.py +++ b/moksha/middleware/connector.py @@ -104,8 +104,10 @@ class MokshaConnectorMiddleware(object): if conn: conn_obj = conn['connector_class'](environ, request) r = conn_obj._dispatch(op, path, remote_params, **dispatch_params) - if not isinstance(r, str): + if not isinstance(r, basestring): r = json.dumps(r, separators=(',',':')) + if isinstance(r, unicode): + r = r.encode('utf-8', 'replace') response = Response(r) else: response = Response(status='404 Not Found')
commit 2c31fe79f5b601b9bdc818e217f3bfbf14b40216 Author: Luke Macken lmacken@redhat.com Date: Sun Mar 22 10:48:29 2009 -0400
Create Moksha's RootController in the MokshaAppDispatcher.__init__
diff --git a/moksha/wsgiapp.py b/moksha/wsgiapp.py index 7ef0b52..aa01376 100644 --- a/moksha/wsgiapp.py +++ b/moksha/wsgiapp.py @@ -27,6 +27,11 @@ class MokshaAppDispatcher(PylonsApp): """ root = None
+ def __init__(self): + super(MokshaAppDispatcher, self).__init__() + from moksha.controllers.root import RootController + self.root = RootController() + def resolve(self, environ, start_response): """ Uses dispatching information found in ``environ['wsgiorg.routing_args']`` to retrieve the application @@ -35,7 +40,4 @@ class MokshaAppDispatcher(PylonsApp):
""" environ['pylons.routes_dict'] = environ['wsgiorg.routing_args'][1] - if not self.root: - from moksha.controllers.root import RootController - self.root = RootController() return self.root
commit f5ec1fc7a80ae65e65006fd1b596fa344b870feb Author: Luke Macken lmacken@redhat.com Date: Sun Mar 22 10:48:06 2009 -0400
Don't utilize pylons.url outside of a request
diff --git a/moksha/controllers/root.py b/moksha/controllers/root.py index 0b66d51..4a3a1a2 100644 --- a/moksha/controllers/root.py +++ b/moksha/controllers/root.py @@ -78,8 +78,10 @@ class RootController(BaseController): return self.docs, remainder
@expose('mako:moksha.templates.login') - def login(self, came_from=url('/')): + def login(self, came_from=None): """Start the user login.""" + if not came_from: + came_from = url('/') login_counter = pylons.request.environ['repoze.who.logins'] if login_counter > 0: flash(_('Wrong credentials'), 'warning') @@ -87,12 +89,14 @@ class RootController(BaseController): came_from=came_from)
@expose() - def post_login(self, came_from=url('/')): + def post_login(self, came_from=None): """ Redirect the user to the initially requested page on successful authentication or redirect her back to the login page if login failed.
""" + if not came_from: + came_from = url('/') if not pylons.request.identity: login_counter = pylons.request.environ['repoze.who.logins'] + 1 redirect(url('/login', came_from=came_from, __logins=login_counter)) @@ -101,11 +105,13 @@ class RootController(BaseController): redirect(came_from)
@expose() - def post_logout(self, came_from=url('/')): + def post_logout(self, came_from=None): """ Redirect the user to the initially requested page on logout and say goodbye as well.
""" flash(_('We hope to see you soon!')) + if not came_from: + came_from = url('/') redirect(came_from)
commit 488173107eab38c2b1890f4bcaca8291e70afb14 Author: Luke Macken lmacken@redhat.com Date: Sat Mar 21 23:44:32 2009 -0400
Properly encode from a unicode string...
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py index 53a72bc..afc9261 100644 --- a/moksha/lib/helpers.py +++ b/moksha/lib/helpers.py @@ -37,7 +37,7 @@ def _update_params(params, d): # recursive dicts also get updated # by the passed params if isinstance(value, unicode): - value = str(value) + value = value.encode('utf8', 'replace') if isinstance(value, dict): value = _update_params(value, d) value = json.dumps(value)
moksha-commits@lists.fedorahosted.org