You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joshua Chamas <jo...@chamas.com> on 2000/05/20 11:33:46 UTC
Re: Apache::ASP #include virtual loses variables
Use file includes. virtual includes are meant to execute
anything and include its output, and is handles by Apache::SSI
outside of Apache::ASP. File includes will be executed as perl
asp subroutines in the same perl namespace as the
including script.
-- Joshua
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks >> free web link monitoring Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
Philip Mak wrote:
>
> Hello,
>
> I have stumbled upon an issue with Apache::ASP <!--#include virtual-->
> directive. Included files do not seem to be able to access the same scope
> of variables. I am using the following test program:
>
> File 1.inc:
>
> <!--#include virtual="2.inc"-->
> <% $test .= '1'; %>
> <p>$test = <%=$test%></p>
>
> File 2.inc:
>
> <% $test = '2'; %>
>
> One would expect the output to be "$test = 21", but it comes out as
> "$test = 1". I have tried the same thing with #include file instead of
> #include virtual and the result is correct.
>
> I am using Apache/1.3.9 on Red Hat Linux. My httpd.conf is setup for ASP
> as follows:
>
> <Files ~ (\.inc)>
> SetHandler perl-script
> PerlSetVar Global /tmp
> PerlSetVar Filter On
> PerlHandler Apache::ASP Apache::SSI
> </Files>
>
> Does anyone know if this is a bug, or a feature, or did I perhaps setup
> ASP incorrectly? Is there a good workaround for this? (It is inconvenient
> for me to use #include file instead since I need to include files relevant
> to DOCUMENT_ROOT, as well as relevant to the location of the current file,
> but I could use that as a last resort.)
>
> Thanks,
>
> -Philip Mak (pmak@aaanime.net)
Re: Apache::ASP #include virtual loses variables
Posted by Joshua Chamas <jo...@chamas.com>.
Philip Mak wrote:
>
> I see. There are two problems that I have with file includes though:
>
> (1) I cannot specify a file's location relative to $ENV{'DOCUMENT_ROOT'}.
>
> (2) I cannot specify a file's location relative to the directory the
> current file is in.
>
> For #1, I want to do something like this in all my pages:
>
> <!--#include virtual="/code/header.asp"-->
> <!--#include virtual="/code/footer.asp"-->
>
For #1, know includes will be picked up from your Global directory,
so you can use that repository to share includes, instead of some
DOCUMENT_ROOT location. You can also use IncludesDir for this if
it is set.
> And for #2, I have an "index.inc" in all my directories. Each index.inc
> has to include the one in its parent directory, e.g.:
>
> <!--#include file="../index.inc"-->
>
> so that directories can pass on properties to their subdirectories. If I
> use include file for that, it will include files relative to the pathname
> of the first ASP file, and not relative to the pathname of the ASP file
> that actually has the include.
>
> ...
> http://www.girlsofanime.com/series/slayers/lina/ has title of
> Girls of Anime::Anime Series::The Slayers::Lina Inverse
>
> The way the title is constructed is:
>
> In /index.inc: $title = 'Girls of Anime';
> /series/index.inc: $title .= '::Anime Series';
> /series/slayers/index.inc: $title .= '::The Slayers';
> /series/slayers/lina/index.inc: $title .= '::Lina Inverse';
>
I would not do it this way, in fact the way I would do this
would not be with your methods at all, unless you want
to have each section to be arbitrarily different and
maintained by separate graphics designers. The way I would
do this thing is to lose the directory structure completely
and to have things be database driven with parameters from
?query_string like /index.asp?dir=1111, which you can build
the title for from the database because you know all the
parents for dir=1111.
The point here is that each ASP script is a whole program
by itself, and I would not recommend having hundreds or
thousands of them to have to compile for your site. If you
have meta data you want to display, you should really stick
as much of it as possible in a database like MySQL. In
the long run, your project will be much more maintainable
even if in the short run its easier to derive info from
unix directories & flat files.
If you want to have a nicer /path_info scheme, we'll
probably have to add a patch for you to have Apache::ASP
not be bound to executing real files as it is currently.
This would be more similar to the way Mason does things.
--Joshua
Re: Apache::ASP #include virtual loses variables
Posted by Philip Mak <pm...@aaanime.net>.
On Sat, 20 May 2000, Joshua Chamas wrote:
> Use file includes. virtual includes are meant to execute
> anything and include its output, and is handles by Apache::SSI
> outside of Apache::ASP. File includes will be executed as perl
> asp subroutines in the same perl namespace as the
> including script.
I see. There are two problems that I have with file includes though:
(1) I cannot specify a file's location relative to $ENV{'DOCUMENT_ROOT'}.
(2) I cannot specify a file's location relative to the directory the
current file is in.
For #1, I want to do something like this in all my pages:
<!--#include virtual="/code/header.asp"-->
<!--#include virtual="/code/footer.asp"-->
And for #2, I have an "index.inc" in all my directories. Each index.inc
has to include the one in its parent directory, e.g.:
<!--#include file="../index.inc"-->
so that directories can pass on properties to their subdirectories. If I
use include file for that, it will include files relative to the pathname
of the first ASP file, and not relative to the pathname of the ASP file
that actually has the include.
One reason I'm coding like this is because I want to give each directory a
title and append it to the page's <title>. e.g.:
http://www.girlsofanime.com/series/slayers/lina/ has title of
Girls of Anime::Anime Series::The Slayers::Lina Inverse
The way the title is constructed is:
In /index.inc: $title = 'Girls of Anime';
/series/index.inc: $title .= '::Anime Series';
/series/slayers/index.inc: $title .= '::The Slayers';
/series/slayers/lina/index.inc: $title .= '::Lina Inverse';
Is there a better way I can do this? Right now I'm thinking of either
trying to hack Apache::ASP to support #include virtual, or using absolute
pathnames or trying to put $ENV{'DOCUMENT_ROOT'} in the file path.
-Philip Mak (pmak@aaanime.net)