Hi all,
I have a weird (and kind of interesting, I hope) problem with $m->redirect in
my Class::DBI based mod_perl/Mason application. (Apache 2.2.3, mod_perl
2.0.2, perl 5.8.7, Mason 1.33, CDBI 3.0.16)
The relevant parts of the component in question:
<%args>
$event # an object from one of my CDBI subclasses; it was instantiated
# in an autohandler and passed to this component in $m->call_next;
</%args>
<%init>
if(deletion confirmed) {
my $dest = (some runtime determined url);
$event->delete;
$m->redirect($dest);
}
</%init>
The failure is that while the server is correctly setting Location to $dest,
it's sending 200 to the browser instead of 302.
I investigated a bit and have a few clues:
1) if I remove the $event->delete line, the redirect works
2) the redirect works if I replace $m->redirect with
$m->clear_buffer;
$r->err_headers_out->set("Location", $dest);
$r->status(302);
3) I tried inlining the code from the CDBI delete method to see if
something in there was to blame; the delete method, after deleting
the data, invalidates the object like this:
undef %$event;
bless $event, 'Class::DBI::Object::Has::Been::Deleted';
When I comment out the call to bless, the redirect works
4) if I retrieve the object from the database within this component:
my $newobj = My::CDBI::Subclass->retrieve($event->id);
$newobj->delete;
the redirect works
I guess what I conclude from this is that after calling delete on the object
passed via the <%args> block (resulting in the re-blessing of the object's
reference), $m gets corrupted such that the redirect fails.
Anyone have any ideas where I should look next?
Regards,
Charlie Katz
Harvard-Smithsonian Center for Astrophysics
[EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users