Thank you very much!<br><br>Devin Jeanpierre<br><br><div class="gmail_quote">On Tue, Feb 22, 2011 at 11:02 AM, <span dir="ltr"><<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 03:46 pm, <a href="mailto:jeanpierreda@gmail.com">jeanpierreda@gmail.com</a> wrote:<br>
>Hello,<br>
><br>
>I want to authenticate a user in twisted.cred by attempting to log him<br>
>in to<br>
>an online service. If the authentication step of the connection fails,<br>
>the<br>
>user gets no avatar, and if it succeeds, the user gets an avatar, and<br>
>that<br>
>avatar either is or has a reference to that connection.<br>
><br>
>How would I do this? I can think of two ugly ways: I can use a global<br>
>dictionary mapping avatarIds to protocol instances, and do a lookup on<br>
>that<br>
>dict in the Realm to create the avatar. Otherwise, I can instantiate<br>
>the<br>
>connection as part of the credentials, and keep the reference to it<br>
>around<br>
>when I get the avatar. I'm going ahead with the former, but it's scary.<br>
><br>
>Another possibility is that perhaps the credentials checker and the<br>
>realm<br>
>could be the same object, and then I could move the global dict into an<br>
>attribute. Would that be a better approach?<br>
<br>
</div>You can do this, but you don't have to. You can also pass the dict to<br>
both the checker initializer and the realm initializer. Now they both<br>
have a reference to it, but it's not global, and they're still separate<br>
objects.<br>
<br>
Jean-Paul<br>
<div class="im">>The background for this is that I have an implementation of the chat<br>
>part of<br>
>the Direct Connect (DC) protocol, and want to write an IRC<->DC bridge.<br>
>I<br>
>chose twisted.words.services on the recommendation of someone, which<br>
>uses<br>
>Cred for auth. DC has authentication as a given nick as part of the<br>
>"handshake" during the start of the connection attempt.<br>
><br>
>Devin Jeanpierre<br>
<br>
</div>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br>