OpenID Launchpad - Header Written problem

61 views
Skip to first unread message

Ronnie

unread,
Jun 19, 2010, 4:07:01 AM6/19/10
to Tornado Web Server
I was trying to build support for Launchpad OpenID. I found that
launchpad uses sreg (http://openid.net/extensions/sreg/1.1) to get
user information (although restricted to only nickname) ->
https://help.launchpad.net/DrupalPlugins#Registering%20your%20site%20with%20Launchpad

The modifications i made can be found in this patch:
http://filebin.ca/zggom/auth.diff

This is the code part i have in my app (mostly copied from
GoogleMixin):
class LaunchpadLogin(tornado.web.RequestHandler,
tornado.auth.OpenIdMixin):
_OPENID_ENDPOINT = "https://login.launchpad.net/+openid"
def get(self):
if self.get_argument("openid.mode", None):

self.get_authenticated_user(self.async_callback(self._on_auth))
return
self.authenticate_redirect(ax_attrs=[],
sreg_attrs=["nickname", "email", "fullname"])

def _on_auth(self, user):
if not user:
raise tornado.web.HTTPError(500, "Launchpad auth failed")
self.set_secure_cookie("user",
tornado.escape.json_encode(user))
self.redirect("/")

The code now stops in self.redirect("/") with the message:
ERROR:root:Exception after headers written
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/tornado/web.py", line
678, in wrapper
return callback(*args, **kwargs)
File "/home/ronnie/Ricochet Robots/server.py", line 49, in _on_auth
self.redirect("/")
File "/usr/local/lib/python2.6/dist-packages/tornado/web.py", line
296, in redirect
raise Exception("Cannot redirect after headers have been written")
Exception: Cannot redirect after headers have been written


Can somebody help?
Ofcource the patch may be included upstream if you want to

Ronnie van den Crommenacker

unread,
Jun 19, 2010, 5:47:17 AM6/19/10
to Tornado Web Server
Ah, found the bug. Looks like i forgot "@tornado.web.asynchronous"
before the get()

Patch still may included upsteam.

Ronnie

Op 19-06-10 10:07, Ronnie schreef:

Reply all
Reply to author
Forward
0 new messages