Neil Gunton wrote:
> I had an idea regarding the issue of having variables which are visible
> to all pages in any request. Currently we get a Request object passed in
> on the stack, which we can set variables in. However I have found this
> to be rather inconvenient due to the extra syntax involved with
> accessing such variables. For instance instead of $foo we now have
> $req->{foo}. As a result I currently include files from base.html into
> the same package. This enables me to have simple variables which are
> shared between files.
I don't know how useful this is to you (or others), but I'm running
Embperl (not EmbperlObject) from my own Apache handler. I do all the
session and component handling from there, and use Embperl for
rendering components. Pretty well all the Embperl .html files start
with:
[! use Steel::EP !]
This imports a bundle of variables into the namespace, which gives me
access to component-level variables $c{xxx} and session-level
variables $s{user}, and the current component URL $page, amongst other
things. This is short and convenient enough for me. Steel::EP
includes a few helper routines as well, but the start is like this,
which is all you'd need to reproduce the variable imports:
#!/usr/bin/perl -w
package Steel::EP;
use strict;
use Steel::Page ();
use Apache::Util qw(escape_uri escape_html);
$^W= 1;
# Importer
sub import {
my $my_pkg = shift; # Should be Steel::EP
my $pkg = caller(0); # Should be Embperl target package
no strict;
#print STDERR "Existing keys in Embperl package `$pkg':\n";
#print STDERR " ", join(" ", keys(%{"${pkg}::"})), "\n";
*{"${pkg}::s"}= *Steel::Page::s;
*{"${pkg}::r"}= *Steel::Page::r;
*{"${pkg}::c"}= *Steel::Page::c;
*{"${pkg}::level"}= *Steel::Page::st_level;
*{"${pkg}::page"}= *Steel::Page::st_page;
*{"${pkg}::comp"}= *Steel::Page::st_comp;
*{"${pkg}::dbh"}= *Steel::Page::dbh;
*{"${pkg}::db"}= *Steel::Page::db;
}
Not completely understanding what you're up to, I don't know if this
is useful or not, but here it is anyway, for what it's worth. Quicker
to cut and paste this than try and invent it from nothing !
Jim
--
Jim Peters / __ | \ Aguazul
/ /| /| )| /| / )|| \
jim@aguazul. \ (_|(_|(_|(_| )(_|I / www.aguazul.
demon.co.uk \ ._) _/ / demon.co.uk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]