Skip to content

Use decorator to define tasks #76

@bitprophet

Description

@bitprophet

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


Closed as Done on 2011-06-09 at 05:49pm EDT

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions