I have a number of chained actions that use an end() method that generates a
json response in a view.

Another developer added an action to support a POST, and at the end of the
action they call $c->visit on a few actions to build up a response -- I
assume to avoid making a few extra ajax requests.  $c->visit does a full
dispatch so auto and end methods are called for each visit, plus for the
original action.  But, because of the chained actions, $c->visit makes
running the requests very simple.

Yes, normally the POST would be followed by a redirect, but this POST is a
file upload in an iframe an a json response is desired.  But, doing this
partial re-dispatch has also come with GET requests.


Any tricks to do a $c->visit type of call but w/o doing a full dispatch,
that is, without calling the auto and end actions?

I suppose I could do something like this, but it's not very pretty.

    for my $action_name ( @action_names_to_run ) {
        local $c->req->{method} = 'GET';
        local $c->request->{arguments} = [];
        local $c->request->{captures}  = [ $item_id ];

        my $action = $c->controller->action_for( $action_name );
        $action = $c->dispatcher->expand_action($action);
        local $c->{action} = $action;

        $action->dispatch( $c );
    }


-- 
Bill Moseley
[email protected]
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to