[Twisted-Python] potential connectSSH workflow

Paul Swartz paulswartz at gmail.com
Thu Jul 26 22:51:17 EDT 2007


On 7/26/07, glyph at divmod.com <glyph at divmod.com> wrote:
> This might seem like a lot of typing, so to help with abbreviation, a
> higher-level object could roll them together:
>
>     altdotssh = DotSSH(FilePath("my-dot-ssh-dir"))
>
> And this leads in to my idea for subtly changing the design.  Instead of
> modifying stuff with arguments to the function:
>
>     defaultConnector.connectSSH(
>         factory, hostname, hostVerifier=altdotssh.hostVerifier)
>
> Building a different object takes roughly the same amount of work and
> does roughly the same thing, but yields a result which can be passed
> around and used as a connector:
>
>     endpt = defaultConfig.endpointSSH(
>         hostname, hostVerifier=altdotssh.hostVerifier)
>     endpt.connect(factory)

So, is defaultConfig is some other object which can create a
ConchEndpoint?  Is defaultConfig a DotSSH?  I'm not clear on what
these different objects are here.

> To push this flexibility even further, you could make the configuration
> object cloneable.
>
>     cfg2 = defaultConfig.copy(hostVerifier=altdotssh.hostVerifier)
>     endpt = cfg2.endpointSSH(hostname)
>     endpt.connect(factory)
>
> although whether this last additional level of flexibility is worth it
> or not probably depends on all of the things that a "configuration"
> object can contain.
>
> Thoughts?

This seems reasonable, at least for the case of host verification.
I'm not sure where authentication fits into these things, though.  It
feels different from host key verification, but moving it to the
connect() method makes the ConchEndpoint a different interface from
the other Endpoints.  I suppose with a copy method:

defaultConfig.copy(user="new username",
authentications=[KeyAuthentication(key),
PasswordAuthentication('password'), InteractiveAuthentication(['answer
1'])]).endPointSSH(hostname).connect()

 is straightforward enough.  But it seems more confusing than:

defaultConfig.endPointSSH(hostname, user="name").connect()

which seems more in line with my personal expectations.  I think,
however, my expectations might be changed if the above example was
more clear to me.

-p
-- 
Paul Swartz
paulswartz at gmail dot com
http://z3p.livejournal.com/
AIM: z3penguin




More information about the Twisted-Python mailing list