R1458 creates an erroneous $gobj->apache_request return?

5 views
Skip to first unread message

Tony Shadwick

unread,
Feb 18, 2011, 10:21:48 AM2/18/11
to Gantry
http://code.google.com/p/gantry/source/diff?spec=svn1458&r=1458&format=side&path=/trunk/lib/Gantry/Plugins/AuthCookie.pm

So I did my first checkout yesterday, and made some additions for
password encryption. Ran bigtop on my own code, everything looked
good, committed.

I suppose I should have more aggressively tested, because things broke
here - however now that I'm looking more closely, it's not my fault -
I don't think? I was running with an older CPAN build prior, and now
when I attempt to go to any do_main that auth_require is set, and I
don't already have a cookie (ie, manually gone to the login controller
first), I get this failure:

Can't call method "param" without a package or object reference at /
usr/local/share/perl/5.10.1/Gantry/Plugins/AuthCookie.pm line 212,
line 481.

The code block in question is highlighted in the link at the top of
this message, starting at line 191 in R1458. The line throwing the
error is 204. Basically this:

my $req = $gobj->apache_request();
...
# Add parameters.
foreach my $param ( $req->param() ) {
**CHOKE**

If I put in debugging code after $gobj->apache_request(), it returns a
scalar value of "1". I'm running this via ./app.server, not mod_perl
or even CGI, yet the $gobj->apache_request command is returning true.
The only references I find to this are in Gantry::Engine::(CGI|MP13|
MP20). In other words, only if you're running via Apache as a cgi or
via mod_perl in Apache 1.2 or Apache 2.

So I guess my question is was this a goof? It looks to me like we're
wanting to get a properly formatted string of the original request so
that we can iterate each of the form parameters passed.

It says this was commited by "net.angelus" - so um...could you fill me
in on your intention here so I can fix my code or fix AuthCookie? :D

John Weigel

unread,
Feb 18, 2011, 12:39:46 PM2/18/11
to gan...@googlegroups.com
It looks like there are a couple options here. The app server uses the
Gantry CGI engine. The apache_request method in the CGI engine doesn't
return anything. If it were changed to return the CGI::Simple object
by returning $self->cgi() that should fix the problem. The CGI::Simple
object has the same param() method as the apache request object. The
other option would be to change the auth_check method to use $self-
>params and then iterate over the hash keys. Since auth_check runs as
a post init callback the params should already be set. Either solution
should work.

-John

> --
> You received this message because you are subscribed to the Google
> Groups "Gantry" group.
> To post to this group, send email to gan...@googlegroups.com.
> To unsubscribe from this group, send email to gantry+un...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/gantry?hl=en
> .

Tony Shadwick

unread,
Feb 18, 2011, 12:48:40 PM2/18/11
to gan...@googlegroups.com
Well, after debugging myself a bit, it appears that fixing the param()
method call is only half the fun. The other is a few lines down:

# Encrypt goto
$goto = $gobj->url_encode( $crypt->encrypt( $goto ) );

The ->url_encode method fails out too, although that could have more to
do with the debugging I was doing than an actual failure. I'll try
switching Engine/CGI.pm to return $self->cgi(), and see how that goes.
If it works cleanly, I'll commit that fix.

Tony Shadwick

Tony Shadwick

unread,
Feb 18, 2011, 3:47:01 PM2/18/11
to gan...@googlegroups.com
Yeah, looks like url_encode is failing from within Engine/CGI.pm - which
makes no sense, as that method is most certainly there...

Can't locate object method "url_encode" via package "MailControl" at
/usr/local/share/perl/5.10.1/Gantry/Plugins/AuthCookie.pm line 223.

I'll keep plugging away at it. If you happen to see anything let me know.

Tony Shadwick

Tony Shadwick

unread,
Feb 18, 2011, 3:53:36 PM2/18/11
to gan...@googlegroups.com
I have to let this drop until later, but I got it working...sorta:

# Encrypt goto
$goto = Gantry::Engine::CGI->url_encode($crypt->encrypt( $goto ));
#$goto = $gobj->url_encode( $crypt->encrypt( $goto ) );

Comment out the line calling it from our $gobj and call it directly, it
works. Call it from the gobj, and suddenly that object method can't be
found. :|

Tony Shadwick

Reply all
Reply to author
Forward
0 new messages