Scott Chapman wrote:
>
> I'm very interested in making a modular site design but haven't
> found the tools yet to allow this with the twist I'm looking for.
>
I'll try to show how Apache::ASP could help here. In Apache::ASP,
scripts can be executed as subroutines, even with return values,
and I think this goes to the heart of what you need here.
I would probably break abstract headers & footers out of
each page, to be called automatically in global.asa. This allows
all pages to not need to know about HTML headers & footers being sent:
# global.asa
sub Script_OnStart { $Response->Include('header.inc'); }
sub Script_OnEnd { $Response->Include('footer.inc'); }
> Say I have a page that encapsulates some functionality, such as
> sending a form then validating the contents that are returned. I'd
> call that PageB.
>
> PageB could be more than one page or a page calling itself, etc.
>
Right ... PageB is just form logic/rendering, headers & footers
are called automatically via events in global.asa.
> When PageA calls PageB, as soon as PageB finishes presenting
> the form it doesn't stop but drops out the bottom and returns
> immediately to PageA. There are commands in some of the tools
> (Mason and soon Embperl - maybe others) to force it to stop there
> but this doesn't make for the modularity I have in mind.
>
#PageA
<% my @rv = $Response->Include('PageB', @args); %>
<!-- Rest of PageA -->
$Response->Include() just calls another page as a perl subroutine
is called with @args passed in as @_ in the script, and @rv returned
if return(@rv) is used in the script too.
> PageB then gets submitted by the user and it either calls itself
> (using conditionals to then do the data validation) or another page.
> After things are validated Ok, I'd like to have it return right back to
> PageA, just where it left off using a "Return" statement. Thus,
> PageA could call a "PageB" and have it do all it's processing then
> return, just like calling a regular subroutine.
>
PageA can execute PageB, and PageB can execute PageA, but this
could cause a loop, so I am not sure what you really want here,
but hope the above showed how one might achieve this.
> 2) are there any tools (preferrably perl) out there that support this
> cleanly. I've worked with Embperl and glanced through the docs of
> Mason, AxKit and TT and didn't see anything looking like this.
>
The $Response->Include() mechanism is very powerful, turning pages
into subroutines, and always returns to the original caller.
To transfer control to another page without returning,
use $Server->Transfer(). This differs from $Response->Redirect()
in that all the globals like $Session/$Application/$Request remain
the same. If the ASP syntax is too ugly for you, you could turn
this into an XMLSub used like:
<page:include file="PageB" arg1="..." arg2="..." />
where you would define:
# global.asa or page.pm or any perl module that gets loaded
sub page::include {
my($args) = @_;
$Response->Include($args->{'file'}, $args);
}
-- Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks Founder Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]