in reply to Apache::DBI and DBI subclasses

I don't have the modules in question in front of me. However my gut feeling is that the right way to go about this is to subclass Apache::DBI. There may be some gotchas to be aware of when you try that. But conceptually it makes more sense to make things work that way, and it is probably possible to succeed in that without any rewriting of Apache::DBI.
  • Comment on Re (tilly) 1: Apache::DBI and DBI subclasses

Replies are listed 'Best First'.
Re: Re (tilly) 1: Apache::DBI and DBI subclasses
by Hrunting (Pilgrim) on Dec 09, 2001 at 20:31 UTC
    Well, the big 'gotcha' with subclasses Apache::DBI is that you can only use it that you need to be running under mod_perl to do it, but I suppose you could do some sort of environment check right before you decide which modules to include and which classes to subclass.
      Well, whether this is doable depends on what you wanted to do. But Perl does have multiple inheritance. You can choose to inherit directly from Apache::DBI and then directly from DBI. So you are a subclass of both, and if Apache::DBI isn't there things still have a chance to work. I say chance because if Apache::DBI and DBI do something differently enough, you might have to work around the difference.

      Another approach is to reconsider doing any subclassing. What you want to do is preserve the interface, right? Well you can have an object that has an attribute which is the database handle it proxies through with an AUTOLOAD method. You can see an example of how to do that at Re (tilly) 1: Reverse Inheritance Irritance. And now you can wrap either one of them without having to do a lot of work...