fab-user
[Top][All Lists]
Advanced

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

[Fab-user] Setting custom variables on env, or in own dict?


From: Paul Walsh
Subject: [Fab-user] Setting custom variables on env, or in own dict?
Date: Sun, 10 Nov 2013 18:17:01 +0200

Hi again,

I've come up against this myself a few times, again, a question of "best 
practices".

I use a configuration object of my own `CONFIG` throughout my package of fab 
tasks. But I continue to be bugged as to whether I should simply put all my 
config directly onto `env`. From the docs, I'm honestly not sure if the 
recommendation is for or against it. Quoting:

"This aspect of env is largely historical: in the past, fabfiles were not pure 
Python and thus the environment was the only way to communicate between tasks.

Nowadays, you may call other tasks or subroutines directly, and even keep 
module-level shared state if you wish.In future versions, Fabric will become 
threadsafe, at which point env may be the only easy/safe way to keep global 
state."

And then I see that in Invoke/Fabric 2, the end object won't exist.


Is there any current best practice in the community on this?

An example:

CONFIG = {
    'staging': {'machine_location': '123.545.232.67', 'machine_port': 80},
    'production': {'machine_location': '123.454.232.24', 'machine_port': 443},
}

In some places I'll merge this with values from `env` too, for example, when I 
set env.user to be owner of a process.

Any advice is appreciated.

Thanks,

Paul.


reply via email to

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