You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Martin Moss <ma...@btopenworld.com> on 2005/05/18 17:30:00 UTC

to ENV or not to ENV

All,

We're in the process of introducing mod perl method
handlers and template toolkit into a system which is
also running Embperl. There is some interaction
between the two, and as Embperl (and especially our
code which uses it) uses %ENV to pass around variables
like $ENV{REMOTE_USER_ID} and other useful things I
wanted to get some views on the use of %ENV in this
form.

I was under the impression that using %ENV is a bad
thing to do.. mod perl provides PerlSetVar to set
variables for mod_perl within conf files... But when a
variable isn't set in a conf file, but in an embperl
script, the way I see it there are several ways to
transfer data between the two systems.

1) using %ENV
2) setting using our own subclass of Apache::Request's
pnotes or notes methods
3) Passed as parameters between them all
4) stored and retrieved through a session store
5) stored in cookies

I think that the whole thing comes down to the first
2... the last few are too impractical (given an
already existing code set) as a generic method... 

I believe that using %ENV opens up the system to bad
coding problems, e.g. writing a backend module for DB
interaction and then slipping in a call to %ENV for
some front end user information. I also believe there
has been some discussion on this list a while ago,
which came out in favour of not using %ENV at all if
it can be helped.... But I can't remember why this was
a bad thing...?

I favour using Apache::Request's pnotes, notes and
dir_config methods for acheiving all of this using
methods as wrappers to the information required....

So can anybody shed some light on this pros/cons
discussion?

Kind regards

Marty


	
	
		
___________________________________________________________ 
Yahoo! Messenger - want a free and easy way to contact your friends online? http://uk.messenger.yahoo.com

Re: to ENV or not to ENV

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, 2005-05-18 at 16:30 +0100, Martin Moss wrote:
> 1) using %ENV
> 2) setting using our own subclass of Apache::Request's
> pnotes or notes methods

I like pnotes because it's guaranteed to get cleared at the end of the
request.

Also, anything you can do via %ENV can be done via any perl global, like
%My::Shared::Var.

> I also believe there
> has been some discussion on this list a while ago,
> which came out in favour of not using %ENV at all if
> it can be helped.... But I can't remember why this was
> a bad thing...?

There are more hoops to jump through for setting %ENV, since those are
actual environment variables.  Might be a problem with threads too, but
I'm not sure about that.

- Perrin