[Twisted-Python] exceptions.TypeError: ('Could not adapt', <twisted.spread.pb._PortalAuthChallenger instance at 0x013E3760>, <InterfaceClass twisted.cred.credentials.IUsernamePassword>)
justinjohnson at gmail.com
Fri Mar 30 13:55:25 EDT 2007
> >Does anyone have any pointers on what I should be looking for here?
> >Is there any way I can accomplish my goal in a more maintainable way?
> It's not clear to me how this worked in the first place. ;) The
> credentials object being adapted to IUsernamePassword should always
> have been a _PortalAuthChallenger, and so it only should have ever
> been adaptable to IUsernameHashedPassword and IUsernameMD5Password.
> The way you want to write requestAvatarId, though, is to inspect the
> credentials object to see what interfaces it provides and them handle
> it accordingly. You can do this by adapting and catching the TypeError,
> adapting with a default and checking for that, or using the providedBy
> method of the interface object. The important point is that you have to
> be able to handle every kind of credentials object which the you have
> declared you can handle (with the credentialInterfaces attribute). In
> this specific case, I believe your checker declared it could handle both
> IUsernamePassword and IUsernameHashedPassword, but its implementation can
> only actually handle IUsernameePassword.
> Hope this helps,
Yes, this is helpful. It has been too long since I looked at this
code. Thank you.
More information about the Twisted-Python