perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew O'Brien" <andr...@oriel.com.au>
Subject RE: sharing data across SSI's (Executes)
Date Tue, 02 Sep 2003 23:41:02 GMT

The obvious difference is that %udat will persist across connections as the values are associated
with the session while anything stored in the request object ($req) will live only for the
life of the request.

Generally, only put data that you want to use on subsequent requests in %udat.

I usually have some sort of constants.epl that is Execute()d from base files to set up constants
across the web request, eg urls of common pages etc. This stores values in $req.

If you just want to pass a variable to the Execute()d file that is not a global then just
pass it in the Execute function call and retrieve it from @param.


Need 1: A variable that persists across all requests for a given browser: use %udat. Eg $udat{key}
= $value

Need 2: A request-specific global variable: store in $req. eg $req->{key} = $value

Need 3: An execute-specific variable, ie a function paramater: pass via the Execute function.

Eg Execute('form.inc', $value1, $value2) or
   Execute({ inputfile=>'form.inc', param=>[$value1,$value2]});

Form.inc:
[- $req = shift;
   ($value1,$value2) = @param; # or
   $value1 = shift @param; $value2 = shift @param; -]

Hope that makes it clearer.

-- 
Andrew O'Brien


> -----Original Message-----
> From: Brian Burke [mailto:bburke@lssi.net] 
> Sent: Wednesday, 3 September 2003 4:27 AM
> To: Embperl
> Cc: Luiz Fernando
> Subject: Re: sharing data across SSI's (Executes)
> 
> 
> 
> Thanks for the advice.  Is there a preference to using
> $req->{test} versus $udat{test} ?
> 
> thanks,
> Brian
> 
> Luiz Fernando wrote:
> 
> > On Thu, 2003-08-28 at 15:17, Brian Burke wrote:
> > > I have an Embperl question that hopefully someone can
> > > help me solve.  Bear with me, I'll try to illustrate the
> > > problem.
> > >
> > > I run apache mod_perl with Embperl 1.3.4.  I realize
> > > this is the old version, but I don't have the time, resources,
> > > or access level to do something about this.  I have code
> > > in which I implement server side includes in embperl
> > > documents using Execute.  example -
> > >
> > > [- $test = true; -]
> > > <html>
> > > <!-- this is index.html -->
> > > [- Execute ('form.inc') -]
> > > </html>
> > >
> > > where form.inc contains html to include for rendering a form.
> > >
> > > My question is, is there a way with Embperl 1.3.4 to
> > > share a perl variable (have the Executed page inherit
> > > the value)?  For example, in the simple index.html
> > > example, above, is there a way for me to access the value
> > > of $test from within form.inc?  Is there a different way to
> > > accomplish this?
> > >
> >
> > Use the req_rec object from mod_perl that is passed to all Executed
> > pages as the first argument in @_.
> >
> > [-
> > $req = shift;
> > $req->{test} = 'true';
> > -]
> > <html>
> > <!-- this is index.html -->
> > [- Execute ('form.inc') -]
> > </html>
> >
> > in form.inc do the same:
> > [-
> > $req = shift;
> > if ($req->{test} eq 'true') {
> >   ...
> > }
> > else {
> >   ...
> > }
> > -]
> >
> > --
> > Luiz Fernando Ribeiro
> > Engenho Soluções S/C Ltda
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message