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">&lt;<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt;</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>
&gt;Hello,<br>
&gt;<br>
&gt;I want to authenticate a user in twisted.cred by attempting to log him<br>
&gt;in to<br>
&gt;an online service. If the authentication step of the connection fails,<br>
&gt;the<br>
&gt;user gets no avatar, and if it succeeds, the user gets an avatar, and<br>
&gt;that<br>
&gt;avatar either is or has a reference to that connection.<br>
&gt;<br>
&gt;How would I do this? I can think of two ugly ways: I can use a global<br>
&gt;dictionary mapping avatarIds to protocol instances, and do a lookup on<br>
&gt;that<br>
&gt;dict in the Realm to create the avatar. Otherwise, I can instantiate<br>
&gt;the<br>
&gt;connection as part of the credentials, and keep the reference to it<br>
&gt;around<br>
&gt;when I get the avatar. I&#39;m going ahead with the former, but it&#39;s scary.<br>
&gt;<br>
&gt;Another possibility is that perhaps the credentials checker and the<br>
&gt;realm<br>
&gt;could be the same object, and then I could move the global dict into an<br>
&gt;attribute. Would that be a better approach?<br>
<br>
</div>You can do this, but you don&#39;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&#39;s not global, and they&#39;re still separate<br>
objects.<br>
<br>
Jean-Paul<br>
<div class="im">&gt;The background for this is that I have an implementation of the chat<br>
&gt;part of<br>
&gt;the Direct Connect (DC) protocol, and want to write an IRC&lt;-&gt;DC bridge.<br>
&gt;I<br>
&gt;chose twisted.words.services on the recommendation of someone, which<br>
&gt;uses<br>
&gt;Cred for auth. DC has authentication as a given nick as part of the<br>
&gt;&quot;handshake&quot; during the start of the connection attempt.<br>
&gt;<br>
&gt;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>