On 03:46 pm, [email protected] wrote: >Hello, > >I want to authenticate a user in twisted.cred by attempting to log him >in to >an online service. If the authentication step of the connection fails, >the >user gets no avatar, and if it succeeds, the user gets an avatar, and >that >avatar either is or has a reference to that connection. > >How would I do this? I can think of two ugly ways: I can use a global >dictionary mapping avatarIds to protocol instances, and do a lookup on >that >dict in the Realm to create the avatar. Otherwise, I can instantiate >the >connection as part of the credentials, and keep the reference to it >around >when I get the avatar. I'm going ahead with the former, but it's scary. > >Another possibility is that perhaps the credentials checker and the >realm >could be the same object, and then I could move the global dict into an >attribute. Would that be a better approach?
You can do this, but you don't have to. You can also pass the dict to both the checker initializer and the realm initializer. Now they both have a reference to it, but it's not global, and they're still separate objects. Jean-Paul >The background for this is that I have an implementation of the chat >part of >the Direct Connect (DC) protocol, and want to write an IRC<->DC bridge. >I >chose twisted.words.services on the recommendation of someone, which >uses >Cred for auth. DC has authentication as a given nick as part of the >"handshake" during the start of the connection attempt. > >Devin Jeanpierre _______________________________________________ Twisted-Python mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
