If you’re on a hosting environment (e.g., bluehost.com) where the only option to run Python/Pylons is via flup (fast cgi), then you may have experienced this error:
<'exceptions.AssertionError'>: write() argument must be string
The bottom line is that the WSGI spec only supports plain strings.
AuthKit, is a middleware that intercepts HTTP request/response in order to enforce authentication and authorization. One issue that you will encounter is that any page that gets rendered via AuthKit by default will be in unicode. This causes flup to throw the above exception. The fix is pretty straight forward:
def render_signin():
result = render('/signin.mako')
result = result.replace('%', '%%').replace('FORM_ACTION', '%s')
return unicode(result).encode('utf8')
Simply cast the result to unicode and encode it to utf8.