On Sun, Sep 25, 2005 at 08:07:58AM -0700, Dean Arnold wrote:
> Tim Bunce wrote:
> > I'm interested to hear stories of people who have subclassed the DBI,
> > or used modules that subclass the DBI.
> 
> My subclasses (or attempted subclasses):
> 
> DBIx::Chart - worked (tho it took me a few years to get it right ;^)
> 
> DBIx::Threaded - didn't work (tho I managed to deliver a "faux" subclass)
> 
> > Was subclassing the DBI a good approach?
> 
> DBIx::Chart - yes, tho it might have been a bit easier
> 
> DBIx::Threaded - no, tho it could have been useful
> but for the magic handle requirement (see below)
> 
> > Where there any problems?
> 
> DBix::Chart - since it was both subclassing, *and* encapsulating/
> aggregating DBI objects, things got a bit confusing as to which
> DBI object's methods/members to expose for any given call. Not certain
> DBI can do anything about that, tho.
> 
> DBIx::Threaded - the requirement that handles *must* go thru
> DBI at some point to acquire "magic" created an insurrmountable
> issue (since the handles returned by DBIx::Threaded's needed to be
> threadsafe and implement Thread::Queue::Queueable). Its not clear
> to me precisely why DBI requires the magic, other than as
> "belt and suspenders" security ? (Or maybe to support the
> tied object mechanism ?)

Yeap, it's due to DBI handles being tied hashes, and that the inner
hash has extra "magic" attached for internal use by the DBI.

> And as I suggested a while
> ago, if an i/f were provided to "conjure" a handle so it
> acquired the needed magic, that might have solved the issue.

DBI::_new_handle() or perhaps DBI::_setup_handle() might help,
but you're deep in the internals there. Followup on dev-dev
if you'd like more info.

> Also, being able to capture the driver-specific methods
> installed via install_method would be nice to support
> same in subclasses such as DBIx::Threaded.

Using AUTOLOAD might provide a way around that.

> > Could it have been done well/better some other way?
> 
> See comments above wrt magic and installed methods.

Thanks Dean.

Anyone else have a DBI subclassing story to tell?

Tim.

Reply via email to