Along vaguely similar lines, I would like Embperl to be able to take a $user
object stored in pnotes and make it accessible as a global in the same way
that e.g. $req_rec is accessible. Would this be possible?

Thanks,

Jonny

J>-----Original Message-----
J>From: Neil Gunton [mailto:[EMAIL PROTECTED]]
J>Sent: Friday, February 09, 2001 5:02 PM
J>To: [EMAIL PROTECTED]
J>Subject: (possibly stupid) idea for EmbperlObject variables
J>
J>
J>Hi Gerald,
J>
J>I had an idea regarding the issue of having variables which 
J>are visible
J>to all pages in any request. Currently we get a Request 
J>object passed in
J>on the stack, which we can set variables in. However I have found this
J>to be rather inconvenient due to the extra syntax involved with
J>accessing such variables. For instance instead of $foo we now have
J>$req->{foo}. As a result I currently include files from base.html into
J>the same package. This enables me to have simple variables which are
J>shared between files.
J>
J>However, there are potential problems with using the same package, and
J>it also short circuits the inheritance mechanisms. 
J>
J>Here's the idea: We currently get certain variables made available to
J>each page, such as %fdat. What if there was an object similar to (but
J>not the same as) $req, where we could set variables; call it, say,
J>$global. Then, we have $global passed in on the stack (like $req). But
J>in addition, we also get all the variables which have been set in
J>$global set directly in the current package, automatically, 
J>like %fdat.
J>
J>For example, in one page we say $global->{foo} = "hello"; then, in
J>another (subsequently executed) page we would have a variable called
J>$foo automatically initialized for us to "hello".
J>
J>If you then change one of these variables, the change is reflected for
J>other pages. I don't know if this is technically possible because I am
J>still a little fuzzy on the details of how Perl manages namespaces and
J>variable references. But, knowing Perl, it should be possible...
J>
J>Does this make any sense? It would enable more global 
J>variables and make
J>it easier to code these, while keeping each page in its own 
J>package, and
J>resulting in tidier code (in my opinion). I'm just thinking about the
J>variables that Embperl currently automatically sets for us - 
J>couldn't it
J>also automatically add references to other variables, based on the
J>contents of an object like $global?
J>
J>This is just an idea, perhaps not fully formed, and I have no idea how
J>hard it would be in practice. Any comments?
J>
J>TIA
J>
J>-Neil
J>
J>---------------------------------------------------------------------
J>To unsubscribe, e-mail: [EMAIL PROTECTED]
J>For additional commands, e-mail: [EMAIL PROTECTED]
J>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to