[Catalyst] InstancePerContext doesn't work in schema
Tomas Doran
bobtfish at bobtfish.net
Thu Jan 14 14:10:22 GMT 2010
Steve Kleiman wrote:
> Having trouble with InstancePerContext in a schema.
This won't work. Ever.
InstancePerContext only works on Catalyst components, the schema isn't a
component, the MyApp::Model::DB class is the component..
You'll want to add InstancePerContext to the model class and get that to
pass stuff down into the schema..
> I'd like to be able to get at $c from within a schema definition. The $callsheet->context call does not throw an error and returns an undef value. So in the case below, I would expect console output to be 'good test' but instead I get "Can't call method "log" on an undefined value".
This is a spectacularly bad idea. Why?
(It's a much better idea to build some closures around $c which you can
call to do things for you, and those pass those into the schema - then
the schema has a coderef it can call to 'generate me a URI', but it
still has no knowledge of Catalyst or $c so seperation of concerns is
maintained).
Cheers
t0m
More information about the Catalyst
mailing list