[Catalyst] Re: Forcing model to reconnect with different
connect_info
kevin montuori
montuori at gmail.com
Thu Dec 10 21:44:22 GMT 2009
>>>>> "AP" == Alex Povolotsky <tarkhil at over.ru> writes:
AP> It's a bit of crazed setup, but I do have it; I have about 100
AP> identicaly-structured based with different conent.
AP> I think it's more reasonable to have one model and set dbname for each
AP> connect. However, I haven't found any way to force model to reconnect
AP> with different connect_info. Maybe someone knows the right handle?
Well, this is (as the comment says) a hack that I whomped up for an
interal-only tool, but it works. If I know I'm going to change DBs, I
just forward off to it.
sub unset_model :Private {
# omg, this is a wicked hack.
my ($self, $c) = @_;
for my $key ( keys %{ $c->stash } ) {
if (ref $c->stash->{$key} eq 'MyApp::Model::DB') {
delete $c->stash->{$key};
return;
}
}
}
I'd love to hear of a better way.
k.
--
kevin montuori
More information about the Catalyst
mailing list