request length global variable

I'm drawing a blank here and I probably shouldn't be, but...

I would like to use a global variable that's only available for the
duration of a request.

I guess I could create() and undef() the variable at the start and end
of each request but that seems so... inelegant...

Any suggestions?

Danke!

Tosh

--
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/
Tosh Cooey [ Fr, 23 April 2010 21:20 ] [ ID #2040094 ]

Re: request length global variable

--000e0cd11a1a22e5ed0484ec794f
Content-Type: text/plain; charset=ISO-8859-1

I've struggled with wanting to use globals too, but it's not the functional
way. Our current approach is to create a parallel request object and pass
that through all of the function calls. We set a member of the parallel
request object to the actual Apache request object. Something like this:

$s->new Session($r, $dbh);

and then in Session,

sub new {
($class, $self->{REQUEST}, $self->{DBH})= [at] _;

and then later

DoStuffWithRequest($s);

It might be neater to just override the Apache request object.




On Fri, Apr 23, 2010 at 2:20 PM, Tosh Cooey <tosh [at] 1200group.com> wrote:

> I'm drawing a blank here and I probably shouldn't be, but...
>
> I would like to use a global variable that's only available for the
> duration of a request.
>
> I guess I could create() and undef() the variable at the start and end of
> each request but that seems so... inelegant...
>
> Any suggestions?
>
> Danke!
>
> Tosh
>
> --
> McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/
>

--000e0cd11a1a22e5ed0484ec794f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I've struggled with wanting to use globals too, but it's not the fu=
nctional way. =A0Our current approach is to create a parallel request objec=
t and pass that through all of the function calls. =A0We set a member of th=
e parallel request object to the actual Apache request object. =A0Something=
like this:<div>
<br></div><div>$s->new Session($r, $dbh);</div><div><br></div><div>and t=
hen in Session,</div><div><br></div><div>sub new {</div><div>=A0=A0($class,=
$self->{REQUEST}, $self->{DBH})=3D [at] _;</div><div><br></div><div>and t=
hen later</div>
<div><br></div><div>DoStuffWithRequest($s);</div><div><br></div><div>It mig=
ht be neater to just override the Apache request object.</div><div><br></di=
v><div><br></div><div><br></div><div><br><div class=3D"gmail_quote">On Fri,=
Apr 23, 2010 at 2:20 PM, Tosh Cooey <span dir=3D"ltr"><<a href=3D"mailt=
o:tosh [at] 1200group.com">tosh [at] 1200group.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex;">I'm drawing a blank here and I probably=
shouldn't be, but...<br>
<br>
I would like to use a global variable that's only available for the dur=
ation of a request.<br>
<br>
I guess I could create() and undef() the variable at the start and end of e=
ach request but that seems so... inelegant...<br>
<br>
Any suggestions?<br>
<br>
Danke!<br>
<br>
Tosh<br><font color=3D"#888888">
<br>
-- <br>
McIntosh Cooey - Twelve Hundred Group LLC - <a href=3D"http://www.1200group=
..com/" target=3D"_blank">http://www.1200group.com/</a><br>
</font></blockquote></div><br></div>

--000e0cd11a1a22e5ed0484ec794f--
Doug Sims [ Fr, 23 April 2010 21:31 ] [ ID #2040095 ]

Re: request length global variable

Tosh Cooey wrote:
> I'm drawing a blank here and I probably shouldn't be, but...
>
> I would like to use a global variable that's only available for the
> duration of a request.
>
> I guess I could create() and undef() the variable at the start and end
> of each request but that seems so... inelegant...
>
> Any suggestions?
>
$r->pnotes() ?
http://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html #C_pnotes_

On the other hand, a global variable can be useful to keep data
*between* requests (within a single Apache child).
To use carefully, but can be very useful.
aw [ Fr, 23 April 2010 21:32 ] [ ID #2040096 ]
Webserver » gmane.comp.apache.mod-perl » request length global variable

Vorheriges Thema: (unknown)
Nächstes Thema: Re: Encoding problem