From 99466026ced8648f9be8057b5264ee8d42dd158c Mon Sep 17 00:00:00 2001 From: "tao.takashi" Date: Mon, 14 Jul 2008 18:44:04 +0000 Subject: [PATCH] added workaround between Linden Lab's Agent Domain implementation which sends the seed cap in the Location: header of a Redirect instead inside LLSD as agent_seed_capability. We now check if the result if a string, then it's the header or if it's an addinfourl object which can be read from and should contain LLSD (the normal behaviour of urllib2). --- pyogp/lib/base/agentdomain.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pyogp/lib/base/agentdomain.py b/pyogp/lib/base/agentdomain.py index 9899fdd..269782d 100644 --- a/pyogp/lib/base/agentdomain.py +++ b/pyogp/lib/base/agentdomain.py @@ -2,6 +2,7 @@ from agent import Agent from interfaces import ICredentialSerializer from caps import SeedCapability import urllib2 +from indra.base import llsd # URL Opener for the agent domain login @@ -30,13 +31,19 @@ class AgentDomain(object): serializer = ICredentialSerializer(credentials) # convert to string via adapter payload = serializer.serialize() headers = serializer.headers - print payload, headers # now create the request. We assume for now that self.uri is the login uri # TODO: make this pluggable so we can use other transports like eventlet in the future # TODO: add logging and error handling - request = urllib2.Request(self.uri,payload,headers) - seed_cap_url = AgentDomainLoginOpener.open(request) + # + request = urllib2.Request(self.uri,payload,headers) + res = AgentDomainLoginOpener.open(request) + if type(res)!=type(""): + seed_cap_url_data = res.read() # it might be an addinfourl object + seed_cap_url = llsd.parse(seed_cap_url_data)['agent_seed_capability'] + else: + # this only happens in the Linden Lab Agent Domain with their redirect + seed_cap_url = res self.seed_cap = SeedCapability('seed_cap', seed_cap_url) return Agent(self)