[Catalyst] Why is $c undefined?

Ian Docherty catalyst at iandocherty.com
Tue Oct 30 11:24:49 GMT 2012


On 30 October 2012 11:09, Craig Chant <craig at homeloanpartnership.com> wrote:
> Thanks Ian,
>
> The hierarchy is something that I am finding mind-blowing at the moment,    "$self->jqgrid->render($self," , you are calling methods jqgrid->render on $self, passing in $self, I'm sure it makes sense to you :-)
>
> One thing I would like clarification with if possible.
>
> Where do I put code that requires the use of more than one model?
>
> Do I create a separate model that acts as an interface between the other models?
>
> You see I have two SQL servers in opposite ends of the country and so I have a model built on Model::DBI that can access one server and another Model that can access the other, but I have functionality that needs data from both , do some calculations and output accordingly.
>
> I assume this does not go in the controller, but I create an interface model with the required methods and functionality that the controller uses?
>
Craig. Yes, try to keep it out of the Controller.

My opinion is, that if you have business logic that uses data from two
SQL servers (each of which has it's own model) then this would be a
model in it's own right. First think of this business logic outside of
Catalyst, it might have accessors for each of the SQL instance
objects. Create a BusinessModel for this logic. You might find that
this then becomes the only Model that you need to access from
Catalyst, and the SQL server objects are not directly called from
Catalyst, but are subsumed by BusinessModel.

Then use Catalyst::Model::Adaptor with your BusinessModel giving
Catalyst access to all of it's methods.

Kind Regards
Ian



More information about the Catalyst mailing list