--- In [EMAIL PROTECTED], Joshua Chamas <[EMAIL PROTECTED]> wrote: > Looking at your solution, I think I would probably do > something more like: > > <my:template href="/templates/simple.html" /> > <my:header>Welcome back, <%= $Session->{'username'} %>! </my:header> > <my:body> > <!--#include file="foo.inc" --> > </my:body> > </my:template> > > This is a more natural use of the XMLSubs in my view, where > inner tags get executed before outer tags.
I agree. I've changed my code to work like this. Of course, now I've run into a new roadblock. Can $Response->Redirect be called from within XMLSubs? I've no trouble with normal <% blocks and accessing objects like $Session, $Response, and such, but redirects seem to be a no go. I have a very simple page like so: <my:template href="/templates/simple.html"> <my:body> <% $Response->Redirect('/bar.html'); print "WHEE!" %> Didn't redirect. </my:body> </my:template> Accessing the page results in no data: $ telnet 63.121.xxx.xxx 80 Trying 63.121.xxx.xxx... Connected to 63.121.xxx.xxx (63.121.xxx.xxx). Escape character is '^]'. GET /env.html HTTP/1.1 Host: xxx.fastweb.com Connection closed by foreign host. I added debug hooks to my::template and my::body-- looking at the error log, I see they're not even being called: [Wed Mar 27 07:50:30 2002] [error] [asp] [6293] [debug] [env.html] - Session_OnEnd 0fa9687de85bb7a63efa76e3be4a4a5a [Wed Mar 27 07:50:30 2002] [error] [asp] [6293] [debug] [env.html] - Application_OnEnd [Wed Mar 27 07:50:30 2002] [error] [asp] [6293] [debug] [env.html] - Application_OnStart [Wed Mar 27 07:50:30 2002] [error] [asp] [6293] [debug] [env.html] - Session_OnStart 09bd6388e1013e29a4522c21480c1669 [Wed Mar 27 07:50:30 2002] [error] [asp] [6293] [debug] [env.html] - Script_OnStart /home/httpd/hosts/fastweb/jobs2/docs/env.html [Wed Mar 27 07:50:30 2002] [error] [asp] [6293] [debug] [env.html] - Script_OnEnd /home/httpd/hosts/fastweb/jobs2/docs/env.html At debug level -3, I can see the redirect is being called: [Wed Mar 27 07:53:50 2002] [error] [asp] [6333] [debug] [1017237230.8886;0.0017] executing __ASP__xxx_env_htmlx4b2b5bcadbb7f3b32a28e389dcd5b4d7 [Wed Mar 27 07:53:50 2002] [error] [asp] [6333] [debug] [1017237230.8892;0.0006] redirect called - location: /bar.html; [Wed Mar 27 07:53:50 2002] [error] [asp] [6333] [debug] [1017237230.8895;0.0003] parsed session into /bar.html?session- id=03d219b11e03c858407d8e4bce265b97 [Wed Mar 27 07:53:50 2002] [error] [asp] [6333] [debug] [1017237230.8897;0.0002] new location after session query parsing /bar.html?session-id=03d219b11e03c858407d8e4bce265b97 [Wed Mar 27 07:53:50 2002] [error] [asp] [6333] [debug] [1017237230.8900;0.0003] Script_OnEnd [Wed Mar 27 07:53:50 2002] [error] [asp] [6333] [debug] [1017237230.8902;0.0002] executing Script_OnEnd [Wed Mar 27 07:53:50 2002] [error] [asp] [6333] [debug] [1017237230.8904;0.0002] [env.html] - Script_OnEnd /home/httpd/hosts/fastweb/jobs2/docs/env.html [Wed Mar 27 07:53:50 2002] [error] [asp] [6333] [debug] [1017237230.8919;0.0015] ASP Done Processing - asp: Apache::ASP=HASH (0x838d090); but there's no output. I created a plain old ASP file like so: <% $Response->Redirect('/bar.html'); print "WHEE!" %> which worked just fine. Any ideas? Any other debugging info I can provide? I'm including my global.asa below. use File::Basename qw(basename); sub Session_OnStart { $Application->{'Session'.$Session->SessionID} = '?'; $Response->Debug("Session_OnStart ". $Session->SessionID); } sub Session_OnEnd { my $t_session_active = time() - $Session->{onstart}; $Application->{'Session'.$Session->SessionID} = $t_session_active; $Response->Debug("Session_OnEnd ". $Session->SessionID); } sub Application_OnStart { $Response->Debug("Application_OnStart"); } sub Application_OnEnd { $Response->Debug("Application_OnEnd"); } sub Script_OnStart { $ENV{'PATH'} = '/bin:/usr/bin'; $Response->Debug("Script_OnStart $0"); $Session->{Started}++; use vars qw(%var %db %error $input); %var = %db = %error = (); $input = $Request->Params; } sub Script_OnEnd { $Response->Debug("Script_OnEnd $0"); $Session->{Ended}++; } sub Script_OnFlush { my $data = $Response->{BinaryRef}; $Response->Debug("Script_OnFlush: about to flush ".length ($$data)." bytes to client"); } $SIG{__DIE__} = \&Carp::confess; sub my::login { $Response->Debug("Entered my::login"); my $args = shift; if ($args->{'type'} eq 'db-only') { # Check the db for the username } else { unless ($Session->{'login'} == 1) { my %param; $param{'URL'} = $ENV{'REQUEST_URI'}; $Response->Redirect( $Server->URL('/login/index.html', \% param) ); } } $Response->Debug("Exited my::login"); } sub my::title { $Response->Debug("Entered my::title"); shift; $var{'TITLE'} .= shift; $Response->Debug("Exited my::title"); } sub my::header { $Response->Debug("Entered my::header"); shift; $var{'HEADER'} .= shift; $Response->Debug("Exited my::header"); } sub my::function { $Response->Debug("Entered my::function"); shift; my $style; if ($var{'FUNCTION_COUNT'} == 0) { $style = 'border:1px solid #58B; background: #8BE'; } elsif ($var{'FUNCTION_COUNT'} == 1) { $style = 'border:1px solid #69C; background: #9CF'; } else { $style = 'border:1px solid #CCC; background: #FFF'; } $var{'FUNCTIONS'} .= <<EOF; <tr> <td align="center" valign="center" height="150" style="$style"> EOF $var{'FUNCTIONS'} .= shift; $var{'FUNCTIONS'} .= <<EOF; </td> </tr> <tr> <td><img src="/spacer.gif" height="1" width="1"></td> </tr> EOF $var{'FUNCTION_COUNT'}++; $Response->Debug("Exited my::function"); } sub my::footer { $Response->Debug("Entered my::footer"); shift; $var{'FOOTER'} .= shift; $Response->Debug("Exited my::footer"); } sub my::body { $Response->Debug("Entered my::body"); my $args = shift; $var{'BODY'} = shift; $Response->Debug("Exited my::body"); } sub my::var { $Response->Debug("Entered my::var"); my ($args, $data) = @_; $data =~ s/^\n//; $data =~ s/\n$//; $var{$args->{'name'}} = $data; $Response->Debug("Exited my::var"); } sub my::template { $Response->Debug("Entered my::template"); my ($args, $data) = @_; $var{'TITLE'} ||= $var{'HEADER'}; $var{'TEMPLATE'} = $Server->MapPath($args->{'href'}); $Response->Include($var{'TEMPLATE'}); $Response->Debug("Exited my::template"); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]