cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Howard <coc...@leverageweb.com>
Subject Re: [flow] session creation
Date Sun, 20 Jul 2003 21:29:55 GMT
I can't look into this now, but wanted to report for anyone who is 
following this discussion that it looks like the session is still being 
created.  I tried:

global constant (created outside function, value never changed after 
declaration)
local constant (created inside function, value never changed)

with both:

cocoon.redirectTo() and
cocoon.sendPage()

If someone wants to do a sanity check, I was just using the simple 
"uncache with flow" example from the event based cache block.

The good news is that I'm digging into the flow implementation a little 
and I'm getting past the "and then some magic happens" level of 
understanding.  This is really impressive stuff.

Geoff

Christopher Oliver wrote:
> Geoff Howard wrote:
> 
>> Thank you for this solution!  Can you explain to my poor pea brain the 
>> difference between a global variable and a global constant in this 
>> context?  IOW, if I want to use global "contants" how do I create and 
>> access them in such a way as to avoid a session?
>>
>> Geoff
> 
> 
> 
> If you assign a global variable outside of a function but never assign 
> it inside a function then no session will be created, as in your earlier 
> example, reproduced here:
> 
>>
>>
>> So (can't test this now) does that mean that even currently, if 
>> instead of:
>>
>> var role = Packages.org.apache.cocoon.caching.Cache.ROLE;
>> function cacheEvent() { ...
>>
>> I do:
>>
>> function cacheEvent() {
>> var role = Packages.org.apache.cocoon.caching.Cache.ROLE;
>> ...
>>
>> I skip the session? 
> 
> As long as you don't assign to "role" inside a function, the session 
> will be skipped in both cases..
> 
> This solution isn't perfect though. If you create a global object and 
> modify its properties, those changes will not be preserved unless you 
> create a session:
> 
>  1  var  myObj = new MyObject();
>  2  myObj.prop = 3;
>  3
>  4   function page1() {
>  5      myObj.prop = 1;
>  6      sendPage("page1.html");
>  7   }
>  8
>  9   function page2() {
> 10       print(myObj.prop); // prints 3 if no session, but 1 if  you 
> have a session
> 11       sendPage("page2.html");
> 12   }
> 
> With no session, the assignments on lines 1-2 will be executed each time 
> the script is called. If you have a session, they will only be executed 
> the first time the script is called.
> 
> Chris


Mime
View raw message