[cgiapp] params, params, params...

Mark Knoop mark at rawcane.net
Mon Feb 11 05:03:10 EST 2008


> On Thu, 2008-02-07 at 10:34 +0000, Mark Knoop wrote:
>
> Hi Mark
>
>> Also I see that CGI::Application has its own params - am I right in 
>> thinking
>> these are completeley different to the query params? Is there any
>> relationship between the two? Should I just be using these for 'global'
>> values?
>>
>> It also looks like I will be using the session plugin and the session 
>> object
>> also has its own params, some of which I would set with the
>> global/query/params that I am interested in.
>
> Perhaps it's clearer if you think in terms of the context of these
> various params():
>
> o Query params carry temporary data from the web client to the web
> server (i.e. from the user to your app)
>
> o CGI::App params hold temporary data in your app for the duration of
> its instantiation
>
> o CGI::Session params hold permanent data (within reason) outside and
> beyond the lifetime of one instantiation of your app. Hence they can be
> used to pass data from one instantiation to the next, with access keyed
> by session id. Hence you need to pass the session key from one
> instantiation to the next. Hence our discussion of the various ways in
> passing that session id (cookies, hidden form data, rewriting URLs)
>
> So, these params() are not directly related to each other at all.

Ok. This is as I thought but it is very useful to have it confirmed in such 
a clear and concise manner.

I am wondering whether it is still useful to set up my own 'globals' object 
with a set of values that are required throughout an instantiation of my 
app, pulled from query params, session params, config and other external 
calls made when the request comes in. This allows me to have some extra 
control over how these values are allocated (eg using the session variables 
if present and obtaining them elsewhere if not, plus performing some 
specific tracing for the getting and setting of certain values) as well as 
allowing me to have a set of class modules which accept a single globals 
object and use whichever specific values are required without me having to 
have lots of different sets of parameters for each one. I'm kinda new to OO 
stuff so I would be interested to know if this is a common practice or if it 
is considered overkill. I have gone down this route and it is working for me 
but I'm not sure it is a good example of encapsulation, loose coupling etc

For example is there another tidy way to make all the params from the 
CGI::App, query and session available in external class methods? Apologies 
if I am being ludicrous due to my lack of understanding of this kind of 
thing but I only learn by asking dumb questions!

Cheers
Mark




More information about the cgiapp mailing list