[Catalyst-dev] Re: [Catalyst] Re: Bug in Catalyst::Model::DBI .15
Jonathan Rockway
jon at jrock.us
Sun May 6 13:01:34 GMT 2007
On Sunday 06 May 2007 04:29:48 am A. Pagaltzis wrote:
> * Evan Carroll <lists at evancarroll.com> [2007-05-06 10:55]:
> > With that said, the patch provided has no drawbacks, and even
> > if you only use the most minimal functionality of M::DBI, with
> > the current code, you don't have a connection until the first
> > ->dbh is called, which is no bueno. (work that is better
> > handled at compile-time)
>
> That is precisely the patch’s drawback. Connecting lazily rather
> than eagerly is a feature.
>
> However, that’s not hard to correct, although the patch would be
> larger: rather than squirreling away a connection in `new`,
> squirrel away a reference to an undef scalar. Then you can assign
> the handle to that scalar, and it will be shared among everyone
> who kept a copy of the same reference.
There's also Scalar::Defer:
my $connection = defer { DBI->connect ... } ;
# not connected yet;
$connection->prepare(...); # bang! connected.
--
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst-dev/attachments/20070506/d0a0cd91/attachment.pgp
More information about the Catalyst-dev
mailing list