-
Notifications
You must be signed in to change notification settings - Fork 2k
Use decorator to define tasks #76
Copy link
Copy link
Closed
Description
Description
Consider using python decorator(s) to define the tasks in fabfile (instead of listing all the callable objects as a tasks).
While I prefer this explicit way, using decorators is also commonly used in projects like Django (http://www.djangoproject.com) and Paver (http://www.blueskyonmars.com/projects/paver/) to define published/callable functions. I'm also aware of methods like importing only the non-callable objects into namespace and using underscore in the beginning of the function, but found it less pythonic.
Using a decorator, it would be also possible to define tasks like 'default' ála Paver.
Example definition:
from fabric.api import local
@task
def mytask():
helperfunc()
local('foobar')
@default
@task
def mydefaulttask():
# run this no command is given
def helperfunc():
# do this an that, not to be used directly
Originally submitted by **** (jmu) on 2009-11-01 at 12:55pm EST
Relations
- Duplicated by Allow developer to specify which functions are tasks #126: Allow developer to specify which functions are tasks
- Duplicated by fab --list should only show functions, not classes #248: fab --list should only show functions, not classes
- Related to Use __call__ instead of __init__ for classes that define one #286: Use call instead of init for classes that define one
- Related to Object-oriented hosts/roles/collections #297: Object-oriented hosts/roles/collections
- Related to Allow for storing/using metadata about hosts #4: Allow for storing/using metadata about hosts
- Related to Make execution model more robust/flexible #21: Make execution model more robust/flexible
- Related to Add namespacing or dot notation #56: Add namespacing or dot notation
Closed as Done on 2011-06-09 at 05:49pm EDT
Reactions are currently unavailable