Hi list,

On Tuesday 25 March 2003 16:37, Shaun Guth wrote:
> sub cgiapp_init
> {
>       my $self = shift;
>       $self->SUPER::cgiapp_init(@_);
>
>       # set your additional runmodes
> }

From the code examples in the cgiapp_init and cgiapp_prerun sections in 
the manual (2.4) I assumed that all runmodes defined in the SUPER 
class, when defined in that class's setup() method, would be 
automagically inherited by the application class. Not so, apparently.

Maybe it goes without saying that the above 
$self->SUPER::cgiapp_init(@_) should be used to actually effectuate the 
inheritance, but I think it might be a valuable addition to the manual. 
And then, why does this work from within cgiapp_init() and _not_ from 
within setup()?

Anyway, I solved the problem by no longer defining my functions by 
_reference_ in the setup() method (thanks Shaun, and Brian too, for 
pointing me to the docs again ;-)  ), and by 'forcedly' inheriting 
runmodes with the above cgiapp_init().

This inheritance mechanism is wonderful. I enjoy C::A more and more each 
time I use it!

>
> On Tue, 2003-03-25 at 00:35, Martijn van den Burg wrote:
> > Hi,
> >
> > I use a base class to handle authentication for my application.
> > It contains the cgiapp_init() and cgiapp_prerun() functions to read
> > the user ID and to set up the database handle, and a setup()
> > function which defines runmodes for 'accessdenied' and
> > 'noconnection'.
> >
> > The derived class says: use base 'MyPackage::Session', and the base
> > class ('Session') says 'use base 'CGI::Application'. I do not
> > meddle with @ISA.
> >
> > When the cgi program runs it creates an instance of the 'derived'
> > class, and then it calls cgiapp_init() and cgiapp_prerun() of the
> > base class. So far so good. But when access must be denied I cannot
> > change to the relevant runmode in the _base_ class, from within
> > cgiapp_prerun(), with 
> > $self->prerun_mode('name_of_runmode_in_base_class').
> >
> > The error message is "No such run-mode 'noconnection'".
> >
> > It appears that the program looks in the _derived_ class for the
> > runmode 'name_of_runmode_in_base_class'.
> >
> > How can I fix this? I'd prefer to have the 'accessdenied' stuff in
> > the base class, so I can reuse it for other packages in the same
> > application.
> >

Kind regards,

Martijn

-- 
+----------------------------------+
        Martijn van den Burg
  ASML, CS PPC [EMAIL PROTECTED] Systems
     Voice: +31 (0)40 268 3856
+----------------------------------+


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[EMAIL PROTECTED]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to