Looks like the documentation is ambiguous. What it means is, that 
particular version of the method doesn't invoke the callbacks. However, 
Capistrano also loads the "Callbacks" module (capistrano/callbacks.rb), 
which overrides the invoke_task_directly method to decorate it with the 
callback calls.

So, you have two options.

First, you can call the task via 
"invoke_task_directly_without_callbacks" (which is what the original 
method is aliased to when the callbacks are added).

Second (and this option is cleaner, I think, but only works when you 
have control over the tasks being invoked): write the target task as a 
vanilla Ruby method, first, and then have the tasks call the method. E.g.


   def do_foo
     puts "foo!"
   end

   task :say_foo_without_bar do
     do_foo
   end

   task :say_foo do
     do_foo
   end

   task :say_bar do
     puts "bar!"
   end

   after :say_foo, :say_bar

It takes a little more planning, but it's less magical, and less 
dependent on internal Capistrano methods.

- Jamis

On 5/12/09 8:02 AM, Emily wrote:
> I'm working on a complex Capistrano recipe that requires being able to
> run a task without callbacks. After some searching through source and
> rdocs, it seems that "execute_task" is the intended way to do this.
> The documentation states that it "executes the task with the given
> name, without invoking any associated callbacks." However, when I run
> a task with execute_task, its callbacks are executed. I also tried
> using invoke_task_directly, which is what execute_task calls
> internally, and that also runs callbacks. Am I misunderstanding the
> purpose of execute_task? Is there some other method I should be using?
> I'm including a minimal Capfile which demonstrates the problem I'm
> having along with the results I'm getting and the results I'm
> expecting.
>
> I've spend a little bit of time trying to figure out what's happening
> with this in the ruby debugger, but with all the meta-programming
> going on in Capistrano, I had a hard time figuring out what's actually
> happening. So I thought that before I spend a whole day digging
> through the source code, I'd see if perhaps anyone else had
> experienced something similar or if I was misinterpreting what
> execute_task is supposed to do.
>
> Thanks in advance for your help,
> - Emily
>
> The capfile:
> task :say_foo_without_callback do
>    t = top.find_task 'say_foo'
>    execute_task t
> end
>
> task :say_foo do
>    puts 'foo!'
> end
>
> task :say_bar do
>    puts 'bar!'
> end
>
> after :say_foo, :say_bar
>
>
> Output from 'cap say_foo':
>    * executing `say_foo'
> foo!
>      triggering after callbacks for `say_foo'
>    * executing `say_bar'
> bar!
>
>
> Output from 'cap say_foo_without_callback':
>    * executing `say_foo_without_callback'
>    * executing `say_foo'
> foo!
>      triggering after callbacks for `say_foo'
>    * executing `say_bar'
> bar!
>
>
> What I would expect from 'cap say_foo_without_callback':
>    * executing `say_foo_without_callback'
>    * executing `say_foo'
> foo!
>
> >

--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to