Thanks for your long answer.

When you create a Catalyst application some tests are created also.
I thought calling the Controller actions could be performed by the
testing framework... (without using a browser)...
I guess I was wrong :)

thanks,
 Edu


2006/6/28, John Napiorkowski <[EMAIL PROTECTED]>:
> I'm not 100% sure I understand your question, but there are a couple of ways 
> to call actions or methods associated with a Controller.  Here are the ways 
> I've found to programmatically call a catalyst action from within my logic, 
> but of course the whole things gets started off with a http request to 
> something:
>
> First, you can use the $c->forward() method.  Using this allows you to 
> forward to an action is has the bonus of passing $c for you automatically.
>
> You can also use
> $c->controller('Foo')->do_stuff; method.  I'm so so familar with this one as 
> I usually don't need it.  I'm sure one of the other experts can fill in why 
> this is useful.
>
> Also you can just 'plain vanilla' methods in your controller class and 
> reference them with $self->method().  This is good when you want to 
> encapsulate functionality without creating an action and poluting the action 
> list needlessly.  You might have:
>
> sub some_form : Public {
>
>  my ($self, $c) = @_;
>
>  if( $self->validate_these($c->request->parameters()) { .....}
>
> }
>
> sub validate_these
> {
>   my $parameters = shift @_;
>
>  #run some validation
> }
>
> This can be really useful if you are subclassing Controller to make your own 
> and want to encapsulate functionality.  Remember, you don't need to make 
> every single method in your controller an action!
>
> There is a $c->detach method which is similar to forwarding but doesn't 
> return to the caller.
>
> You can also use the subrequest plugin to call an action.  That is a lot like 
> forwarding but it creates a totally new catalyst request.  I've used this 
> when trying to mimic a portal where the main page calls a bunch of URIs to 
> assemble itself.
>
> If you want to call a catalyst action from outside the catalyst framework, 
> I've used LWP to call URIs from things like cron jobs, etc.  I don't know if 
> there is a way to access catalyst any other way.
>
> I think that covers the ways and whys I've found with controller actions.  
> Good Luck!  --john
>
> ----- Original Message ----
> From: Eduardo Oliveros <[EMAIL PROTECTED]>
> To: The elegant MVC web framework <[email protected]>
> Sent: Wednesday, June 28, 2006 5:11:27 PM
> Subject: Re: [Catalyst] Program the logic
>
> That leads to a new question:
> Is possible to call actions in the Controller without using a web browser?
>
> Thanks,
> --edu
>
> PD: I'll use DBIx::Class, sounds promising.
>
> 2006/6/28, Nilson Santos Figueiredo Junior <[EMAIL PROTECTED]>:
> > On 6/28/06, Eduardo Oliveros <[EMAIL PROTECTED]> wrote:
> > > I'm planning to program the logic of the application (the Model in
> > > MVC) previously to start with web page and the presentation.
> >
> > Actually, the Controller is what is supposed to drive the logic of the
> > application. The model is really just that: the model. It's usually
> > mapped to some kind of storage engine such as a RDBMS. Many strong
> > advocates of MVC specifically try to leave business logic out of the
> > database.
> >
> > > What I see is that what Catalyst calls Model is just the Objects that
> > > map with the tables in the DDBB. And the logic of the application are
> > > developed in the Actions (in fact linked to the web application).
> >
> > You'll see that it's "a little" more than that (at least when you're
> > using DBIx::Class - Class::DBI can't even be compared feature-wise
> > nowadays).
> >
> > > I know is difficult in practice to separate both worlds (logic from
> > > the presentation) but that is the false promise of the MVC pattern :).
> >
> > Not really. It's something somewhat straight-forward when using
> > something like Catalyst. All you've got to do is resist the temptation
> > of polluting your controllers with things that really should be in
> > your views. But sometimes it's even worth it.
> >
> > -Nilson Santos F. Jr.
> >
> > _______________________________________________
> > List: [email protected]
> > Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> > Searchable archive: http://www.mail-archive.com/[email protected]/
> > Dev site: http://dev.catalyst.perl.org/
> >
>
> _______________________________________________
> List: [email protected]
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/[email protected]/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
>
> _______________________________________________
> List: [email protected]
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/[email protected]/
> Dev site: http://dev.catalyst.perl.org/
>

_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to