<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV>I'm working on adding a Seaside layer to one of my legacy systems (it's fun to call Rails "legacy", eh?). As I try to link back and forth from the old code to the new, I'm finding that I need my session state preserved across exits and entries.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>As an example, I have built a hierarchy navigation component in Seaside, and it remembers the account you selected last time you used it. So each time I call the component, the hierarchy is still open to the last account that the user selected.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I'd love to use this from Rails, but each time I follow the link to /seaside/selectAccount, it starts me with a fresh session and I lose my old state. The cool remembering trick never gets to show its stuff.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The solution I've come up with is hackish, which is why I'm asking for input here. Essentially, I'm subclassing WAApplication and using the Rails cookie as the session key. That way, my old session can be found when the user re-enters Seaside.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>This works for me, at this point. LegacyOverlay is a subclass of WAApplication:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BLOCKQUOTE type="cite"><DIV>sessionCookieField</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>^'_session_id'</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>registerRequestHandler: anObject </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>| key |</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>(anObject isKindOf: Seaside.WASession) </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>ifFalse: [^super registerRequestHandler: anObject].</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>key := Seaside.WAExternalID </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                                </SPAN>fromString: (anObject currentRequest cookies at: self sessionCookieField).</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>self shouldCollectHandlers ifTrue: [self unregisterExpiredHandlers].</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>self mutex critical: </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                        </SPAN>[handlersByKey at: key put: anObject.</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                        </SPAN>keysByHandler at: anObject put: key].</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>^key</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>handleDefaultRequest: aRequest </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>| sessionKey existingSession |</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>sessionKey := aRequest cookies at: self sessionCookieField</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                                </SPAN>ifAbsent: [^self redirectToLoginPage: aRequest].</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>existingSession := handlersByKey at: (Seaside.WAExternalID fromString: sessionKey)</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                                </SPAN>ifAbsent: [^super handleDefaultRequest: aRequest].</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>^existingSession handleRequest: aRequest</DIV></BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Am I on the right track, or is there an easier way to accomplish this? Since I'm overlaying my Seaside app on an existing system, the app needs to behave as if it has multiple entry points. I just don't want it to start over every time it is entered.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>For my account selection component, I'm just storing the last selected account in an instance variable in the session. That means that simply locating the previous session is enough to make my component do its magic. At some point I'd rather do something less "global", like an instance variable in a component that I instantiate once and repeatedly call, but I'm not familiar enough with the internals quite yet to make it work that way.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">--</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">Ken Treis</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">Miriam Technologies, Inc.</FONT></P>  </DIV><BR></DIV></BODY></HTML>