kmike/fabric-taskset — pull request #1 by amyers (2012-07-12 22:58:38+00:00)
Title: Added runs_once_per_instance decorator

I added a runs_once_per_instance decorator, because with runs_once, the decorated method only runs once per python invocation -- including on descendants. Example:

```python
# base.py
from taskset import TaskSet, task
from fabric.api import runs_once

class Base(TaskSet):
@runs_once
@task
def once(self):
print('only runs once, ever')

@runs_once_per_instance
@task
def per_instance(self):
print('runs once per instance')

# foo.py
from base import Base

class Foo(Base):
pass

instance = Foo()
instance.expose_to_current_module()

# bar.py
from base import Base

class Bar(Base):
pass

instance = Bar()
instance.expose_to_current_module()

# fabfile.py
import foo
import bar
```

```bash
$ fab foo.once bar.once
only runs once, ever

Done.
$ fab foo.per_instance bar.per_instance
runs once per instance
runs once per instance

Done.
```