<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">I realized overnight that I was making this a lot harder than it needed to be. If I just configured my Seaside app to use session cookies, I'd get the same session at every re-entry. There's no reason why the Seaside cookie needs to match the Rails cookie.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>But I'd still appreciate some feedback on how to keep some state (like the last selected account in my example component below) across entries. Is a custom subclass of WASession the best place to store this?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Ken</DIV><DIV> <BR><DIV><DIV>On Feb 18, 2007, at 12:26 AM, Ken Treis wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><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><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">--</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">Ken Treis</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">Miriam Technologies, Inc.</FONT></DIV>  </DIV><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Seaside mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:Seaside@lists.squeakfoundation.org">Seaside@lists.squeakfoundation.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside</A></DIV> </BLOCKQUOTE></DIV><BR><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>