logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Superclass question (new to OO): msg#00049

Subject: Superclass question (new to OO)
I have a question about using superclasses in C::A. Using the example in the
C::A documentation, I have had a superclass (myApp.pm) for a long time. It
contains routines common to the application (cgiapp_init, etc.).

Today, I got the idea of having multiple levels of inheritance. I thought I
would move some extremely generic methods to "webApp.pm" so they could be
the base for any web application. The inheritance looks like this:

================
genericApp.pm
  package genericApp;
  use base 'CGI::Application';
  - logging method
  - Other generic web methods useful for any particular application.

myApp.pm
  package myApp;
  use base 'genericApp';
  - cgiapp_init
  - other methods generic to one particular web application.

object.pm
  package object;
  use base 'myApp';
  - The customary CGI::App object. Contains "setup" and the run-mode
methods.

cgi-bin script
  use object
  $object = object->new();
  $object->run();
=================

Everything regarding C::A's functionality works fine. The lowest level
instantiation finds the "run" method in the higest level base class of C::A.

The problem is, when I reference the logging method (which is in myApp.pm)
from anywhere (as $self->loging(), or as "$object->loggin() in the lowest
level cgi-bin script") it fails with "undefined subroutine."

I don't understand Perl's OO. But, I modelled this chain of inheritance
using small Perl scripts executed from a command line. It works fine.

Should the above type of layered inheritance work? I'm trying to understand
if I've done something wrong, or if I'm trying to do something that won't
work.

Thanks!
Mark


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@xxxxxxxxxxxxxxxxx/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: cgiapp-unsubscribe@xxxxxxxxxxxxxxxxx
For additional commands, e-mail: cgiapp-help@xxxxxxxxxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>