Rhesa Rozendaal wrote:
Richard Jones wrote:
[..]
The problem seems to be that, according to the docs, RunmodeDeclare will capture variables passed as $self->baz(1, "me") as well as from the query object. So 'edit ($id)' means $id will capture anything passed into the rm. What seems odd is that the dfv errors hashref is also captured in the first arg shifted from @_:

That's the issue: the arguments aren't shifted off @_, they're assigned from it. CAP::RD rewrites this:

  runmode something ($some, $variables)

into this:

  sub something {
    my $self = shift;
    my ($some, $variables) = @_;

    $some = $self->query->param('some') unless defined $some;
    $some = $self->param('some')        unless defined $some;
    ...

In other words, it tries treating the signature as a regular method signature first, and only falls back to looking in $self->query or $self->param if the variables are still undefined.

And it also explains why you got the errs hashref in both $id and $errs, since @_ is still unchanged.


runmode edit ($id) {
   my $errs = shift;

   warn Dumper $id; # contains the dfv errors hashref
   warn Dumper $errs; # also contains the dfv errors hashref !!

   [ .. ]
}

Of course it all works fine if I switch back to conventional runmode handling, or to AutoRunmode.

The other solution would be to recognise that dfv_error_page passes the dfv hashref as the first argument, and name that in your signature:

  runmode edit ($errs, $id) { ...

That way, $errs is picked up from @_, while $id is picked up from either $self->query or $self->param (provided dfv_error_page doesn't pass additional parameters).

Hi Rhesa,

OK, first thoughts (without actually trying it), are that "runmode edit ($errs, $id)" would work OK for the error return from update(), but not when edit() is called from the query - as /myapp/edit/1 - since the value of '1' would get taken into $errs, leaving $id undef. No?
--
Richard Jones

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to