fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] Generic prefix context manager?


From: Jeff Forcier
Subject: Re: [Fab-user] Generic prefix context manager?
Date: Tue, 7 Jul 2009 21:58:55 -0400

> I might take a shot at this.  Do you have a design in mind, or do you
> want to see what I can come up with?

Offhand I was probably going to approach it in a similar manner to
your example: env.prefixes as a list, with each invocation of the
context manager appending as it enters, then popping as it exits (just
like the rest of the context managers do) and being referenced like
'cd' is now, within run() and sudo() and wherever else I patched that
in.

Then cd() would be reimplemented as something that just calls the new
context manager with "cd <my argument>".

> More generally, I think it would be nice if the code that builds up
> strings to be used as commands was totally separate from the code that
> executes those commands.  Then a dry-run mode might be easier.

Not a bad idea; more importantly, I need to merge run() and sudo()
because they duplicate a lot of code right now, and the more we start
monkeying with call chaining and prefixing and such, the more that DRY
violation is going to hurt. Once that's done, this sort of thing will
be easier to look at and decide upon.

-Jeff




reply via email to

[Prev in Thread] Current Thread [Next in Thread]