DBI::connect_via (was: OO Architecture)
[email protected] (Tim Bunce) Wed, 28 Sep 2005 17:11:40 +0100
| Newsgroups | perl.dbi2.dev |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Sep 28, 2005 at 11:54:09AM +0200, Honza Pazdziora wrote:
> On Tue, Sep 27, 2005 at 11:55:20PM -0700, Ask Bj?rn Hansen wrote:
> > On Sep 27, 2005, at 23:45 , Jeff Urlwin wrote:
> >
> > >Hmm...isn't Apache::DBI an example?
> >
> > No, it's not subclassing DBI. (DBI sets "connect_via" to
> > Apache::DBI::connect if it sees that Apache::DBI is loaded).
>
> Actually, Apache::DBI not only is not a subclass, it is a nasty
> hack in DBI. ;-) Even if greatly usefull. I cannot write my own
> module MySite::PersistentDBI and get the same prominent handling from
> DBI as Apache::DBI gets.
>
> (Actually I could if the code in DBI.pm be changed to
>
> if (not defined $DBI::connect_via) {
> $DBI::connect_via = "connect";
> }
>
> and have Apache::DBI do
>
> $DBI::connect_via = "Apache::DBI::connect";
>
> Tim, could you spend two lines on why didn't you use this approach?)
I'd happily accept a patch. Could just be
- $DBI::connect_via = "connect";
+ $DBI::connect_via ||= "connect";
and some docs, of course :)
Meanwhile, just have MySite::PersistentDBI "use DBI;" before then
setting $DBI::connect_via itself.
Tim.