[Twisted-Python] Assigning AMP box senders & receivers from the responder

Laurens Van Houtven _ at lvh.cc
Wed Jul 4 03:39:43 EDT 2012


On 03 Jul 2012, at 23:53, Glyph wrote:

> 
> On Jul 3, 2012, at 12:08 AM, Laurens Van Houtven <_ at lvh.cc> wrote:
> 
>> I'm trying to implement a command called "Become" that allows a staff member to work as if he was the user himself. The most obvious way (to me at least) to do that  to create the customer API (an IBoxReceiver/amp.BoxDispatcher subclass) for that customer (that'd normally be the Realm's job -- but since we're already logged in as an administrator, we don't go through Cred again), and hook up the current connection with that box receiver. Yay, code reuse!
> 
> Why not just go through cred again?  (If you look for 'Preauthenticated' in the Divmod code base you'll find that this is actually something of a design pattern.)

I haven't seen that class, I'll take a look.

I didn't want to go through fred again because I don't see the benefit. I'm not trying to do any authentication (that part's already done), admins don't know the relevant password, so it'd pretty much be IRealm.requestAvatar. I don't understand why portal, credentials checkers... come into play.

>> I don't see an obvious way to get a reference to the boxReceiver/boxSender from the responder method using documented APIs. Does this just mean I have to leak a reference to them all the way down? Am I doing something stupid?
> 
> This is why the lowest level of argument parsing is fromString*Proto* rather than just fromString.  You can write an Argument that doesn't actually look at the box and gives you any necessary properties from the protocol (or from the transport).  It was originally written so you can ask for the host and peer addresses for P2P stuff, but this is another possible use.

So what would this custom Argument be? Right now I take the user id of the user I'm trying to be.

> Sorry I don't have time to be more expansive at the moment, I hope that's enough to get you un-stuck,

Afraid not :( That's okay, I have different tests to go fix :)

> 
> -glyph
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python




More information about the Twisted-Python mailing list