On Jul 3, 2012, at 12:08 AM, Laurens Van Houtven <_...@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 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.
Sorry I don't have time to be more expansive at the moment, I hope that's
enough to get you un-stuck,
-glyph
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python