I think you've got something wrong about that subclassing. The superclass doesn't know its subclasses, only the subclass knows its superclasses as they are in @ISA. The base pragma only puts a class into @ISA.

Now, whenever a method in the subclass is called and not found there, it is searched for in all classes that stand in @ISA of that package:

package Superclass; sub foo { print "Superclass::foo( @_ )\n" } sub bar { print "Superclass::bar( @_ )\n" } package Subclass; use base 'Superclass'; sub bar { print "Subclass::bar( @_ )\n" } package main; Subclass->foo; #Superclass::foo( Subclass ) Subclass->bar; #Subclass::bar( Subclass )

If you make Class::DBI create a 'sessions()' method for "Super::Person" and "Sub::Person" has "Super::Person" in its @ISA, you can be sure that perl will look for 'sessions()' in "Super::Person" if it doesn't find it in "Sub::Person", but the first parameter passed to 'sessions' will be "Sub::Person". Just get rid of that __PACKAGE__, it only makes you unflexible.

--
http://fruiture.de

In reply to Re: __PACKAGE__ in subclass by fruiture
in thread __PACKAGE__ in subclass by thpfft

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.