[Maypole] Odd (lack of) inheritence issue
Nic Gibson
nicg@noslogan.org
Sat, 24 Jul 2004 22:21:19 +0100
--huq684BweRXVnRxX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Whilst tracking down a problem last night I discovered that I don't appear
to be able to override :Exported methods defined in Maypole::Model::CDBI.
Now, it's entirely possible that I'm doing something dumb here.
I have a model class. It overrides do_edit very simply - I've added an
include path to the constructor for CGI::Untaint so that we can get
at some custom 'untainters'. So, it's basically the same as the
original in Maypole::Model::CDBI but I've added a line or so.
However, it doesn't get called. I'm relatively certain I'm doing
something blindingly stupid. However, I'm having a trees and wood problem
right now. I've attached my model class. Can anyone see where I've
gone wrong?
It's probably important to note that my table classes are all in
separate modules and there's a
BEGIN {PMR->setup...}
at the start of the driver module, just before the 'use PMR::BaseOnModel'
lines.
Heyulp?
nic
--
the revolution will not be not rerun brothers
the revolution will be live
--huq684BweRXVnRxX
Content-Type: application/x-perl
Content-Disposition: attachment; filename="Model.pm"
Content-Transfer-Encoding: quoted-printable
package PMR::Model;=0A=0Ause strict;=0Ause warnings;=0A=0Ause base qw(Maypo=
le::Model::CDBI);=0A=0Asub do_edit :Exported {=0A my ($self, $r) =3D @_;=
=0A my $h =3D CGI::Untaint->new(=0A {INCLUDE_PATH =3D> $r->config->{un=
taint_prefix}},=0A %{$r->{params}});=0A my $creating =3D 0;=0A my (=
$obj) =3D @{$r->objects || []};=0A if ($obj) {=0A # We have somet=
hing to edit=0A $obj->update_from_cgi($h =3D> {=0A require=
d =3D> $r->{config}{$r->{table}}{required_cols} || [],=0A =
});=0A } else {=0A $obj =3D $self->create_from_=
cgi($h =3D> {=0A required =3D> $r->{config}{$r->{table}}{required=
_cols} || [],=0A });=0A $creating=
++;=0A }=0A if (my %errors =3D $obj->cgi_update_errors) {=0A #=
Set it up as it was:=0A $r->{template_args}{cgi_params} =3D $r->{pa=
rams};=0A $r->{template_args}{errors} =3D \%errors;=0A $r->{t=
emplate} =3D "edit";=0A undef $obj if $creating; # Couldn't create=
=0A } else {=0A $r->{template} =3D "view";=0A }=0A $r->obje=
cts([ $obj ]);=0A}=0A=0A=0A1;=0A
--huq684BweRXVnRxX--