RE: [Seaside-dev] Re: Making '_k' and '_s' optional: A Seaside Heresy?

Ramon Leon ramon.leon at allresnet.com
Sun Aug 24 00:03:59 UTC 2008


> Hi Julien,
> 
> Here is the list of changes:
> 
> - Extension of WAAnchorTag for URLs we know are internal page links,  
> which removes _k and _s if the user is not logged in, and 
> creates the  
> nice URL.
> - The session key is removed from action URLs if there exists a  
> session cookie (in Session>>actionUrlForKey:).
> - RenderLoopMain>>start: parses the requested URL to initialize the  
> components to the appropriate page
> 
> With this strategy, the following two changes allow us to fulfill  
> another requirement, which is that we do not want to do an initial  
> redirect with the _c flag in to support session cookies. We did not  
> like the default behavior because (i) of the additional roundtrip  
> (which also happens before a 404 response and hence defeats HEAD  
> requests e.g., from search bots or validators) and (ii) the _c flag  
> that is set to avoid recursion. Furthermore, with the session key  
> fallback into URL, search engines still see the _s key.
> 
> - Session>>returnResponse: adds a cookie to the response if none is  
> set (if there exists one that is invalid, the code in WARegistry/ 
> WAApplication removes the cookie when redirecting. Hence, when there  
> is one, we assume that it is also valid)
> - The #useSessionCookie configuration setting is disabled to 
> avoid the  
> default fallback
> 
> That's pretty much it... in total this is just a hand full of  
> overrides in subclasses. I haven't noticed any problem or limitation  
> so far.
> 
> Adrian

That's a very nice approach and I like adding the cookie without
redirecting.  Though it keeps the current session, it still looks like a new
request which creates a new instance of the #rootComponent for every hit.
You lose any state that component may have had, assuming the #rootComponent
was a container around the current page state you're loading.  I use my own
homebrew cms and this didn't quite work because of that.

With a few small additions I got it working great.  I hold the current
instance of the #rootComponent as an instance var in the session and
override #start: passing on the #rootComponent instance.

start: aRequest
    ^ self mainClass new
          cms: cms;
          start: aRequest

And then override #createRoot on my RenderLoop like so...

createRoot
    ^ cms ifNil: [ self rootClass new ]

Which then reuses the existing instance of #rootComponent allowing me to
keep my url parsing code in #initialRequest: on the #rootComponent, now kept
in place because of the session and keeps its state allowing me to use keep
up the toolbars visible when the user is logged in and working on the pages
and navigating around.  The urls are now generated as ordinary href's
between internal page links without generating any continuations.  Thanks
for sharing this.

Ramon Leon
http://onsmalltalk.com



More information about the seaside-dev mailing list