On Fri, 2006-10-27 at 18:53 +0100, Josef Karthauser wrote: > So another question if I may. I'm an experienced perl programmer, but > I didn't know about attributes until I installed maypole.
That makes two of us :) > So, I want to add a logout() method, i.e.: > > sub logout : Exported { > my ($class, $r) = @_; > # Remove the user from the request object > my $user = delete $r->{user}; > # Destroy the session > tied(%{$r->{session}})->delete; > # Send a new cookie which expires the previous one > my $cookie = Apache::Cookie->new($r->{ar}, > -name => $r->config->{auth}{cookie_name}, > -value => undef, > -path => "/" > -expires => "-10m" > ); > $cookie->bake(); > # Template switcheroo > $r->template("frontpage"); > } > > which I have added to my toplevel class, i.e. BeerDB.pm, but I get > this error in the browser: > > Invalid CODE attribute: Exported at BeerDB.pm line 52 This is a frequent gotcha. Your best bet is to look through the archive, because I don't remember the current details. My answer is always that this is an action (because of the Exported attribute, yes ?) and actions belong in the model class, not the controller. Then IIRC, Aaron points out that you can now put it in the controller if you want and somebody else will point out that it's to do with compile-time versus run-time which is documented in the cookbook. Or something like that. It's too late for a better answer. The important thing is the knowledge that the answer is in the archive of this list. Cheers, Dave > Do I need to do anything special? I'm starting the module off with: > > use Maypole::Constants; > use Maypole::Application qw(Authentication::UserSessionCookie); ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Maypole-users mailing list Maypole-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/maypole-users