I need to get login credentials for some pages that might be deep
linked. I have a LoginForm component that gets called, returning the user if its found: authenticate (AccountRepository find: domain verify: password) ifNotNil: [ self answer: account. ]. authenticate is called when the login form is submitted. So how do I get to render the login form? Well I started off with a LoginDecoration. It looks like renderContentOn: html self session account ifNotNil: [ self renderOwnerOn: html. ] ifNil: [ self session account: (self call: ANLoginForm new) ]. WADecorations don't have call: though. So I tried doing the call directly from my component requiring an authenticated user: renderContentOn: html self requireLogin. "the stuff that I render after I have a logged in user" requireLogin self session account ifNil: [self session account: (self call: ANLoginForm new)]. When I tried this, I got the following error: MessageNotUnderstood: UndefinedObject>>updateStates: WARenderContinuation(WASessionContinuation)>>updateStates: [] in WARenderContinuation(WASessionContinuation)>>respond: {[:value | self updateStates: states]} [] in ANSession(WASession)>>onRespond: {[:response | aBlock value: response. previous value: response]} ANSession(WASession)>>returnResponse: ANSession(WASession)>>pageIntentionallyLeftBlank [] in ANSession(WASession)>>withEscapeContinuation: {[:cc | escapeContinuation := cc. aBlock value. self pageIntentionallyLeft...]} EscapeContinuation class(Continuation class)>>currentDo: ANSession(WASession)>>withEscapeContinuation: ANSession(WASession)>>responseForRequest: [] in ANSession(WASession)>>incomingRequest: {[self responseForRequest: aRequest]} BlockContext>>on:do: [] in WAProcessMonitor>>critical:ifError: {[value := aBlock on: Error do: anErrorBlock]} BlockContext>>ensure: [] in WAProcessMonitor>>critical:ifError: {[[value := aBlock on: Error do: anErrorBlock] ensure: [semaphore signal]]} [] in BlockContext>>newProcess {[self value. Processor terminateActive]} No clue what that means, couldn't find anything on google, and this errors without all the nice seaside links so I'm not able to fire up the debugger. I read in http://www.shaffer-consulting.com/david/Seaside/CallAnswer/index.html that you shouldn't use call from within renderContentOn. I don't know if that means that call *doesn't work* from within renderContentOn, or it's just a style thing. Anyway...all I want to do is, when I begin to render a page, check for an account in the session and if it doesn't exist prompt a login. I'm sure this is simple and I'm just doing something stupid at this point. Can anyone help out? Pat _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
I changed the LoginForm component to set the account in the session
instead of using answer. Now my LoginDecoration renders the LoginForm when there's no user in the session. Now I'm running into a problem with children. The LoginForm isn't in my main component's children list...which, there's really no way it could be - the main component doesn't know anything about the LoginForm, it only gets created as a result of my Decoration. I verified that this is the problem by moving all the code from my LoginForm into my LoginDecoration, and it works fine. So again I think I'm doing something stupid here. I'm somewhat close in that I can get the decoration to render my LoginForm component, but now that component has to go into the decorated component's children (apparently). That feels ugly so I would think there's a better way to do this. Pat _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
you might try overriding the states method to return your decoration
John On Wed, May 27, 2009 at 10:21 PM, Pat Maddox <[hidden email]> wrote: I changed the LoginForm component to set the account in the session -- http://jmck.seasidehosting.st _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Pat Maddox-2
What does your LoginForm do? Does it have persistent state? If not,
why not have the LoginDecoration do the rendering itself? Or if you just want it factored out but don't need state or call/answer just implement a class that has a #renderOn: method and pass that to "html render:" (any object can render itself and only Components need to be listed in #children). This stuff is all a bit clearer, I think, in 2.9 (not that I'm suggesting you should start using it - just saying you're right to find it problematic). Otherwise... hm Seaside 2.8 doesn't have #children on WADecoration does it? That's fixed in 2.9 too. :) I guess if you really needed component features on LoginForm you would implement #nextPresentersDo: on your Decoration to make sure it evaluates the block for the child component. And to answer your earlier question, calling or answering while rendering just doesn't make sense. I can't remember what the failure mode is in 2.8 (in 2.9 it will definitely fail completely) but the continuations don't work right if you try to do that. Rendering shouldn't really change state - it should just render the current state so that it can be done over and over again. (this doesn't feel like my most articulate post ever but I'm on my way to bed - I'm sure the European contingent can clarify anything that doesn't make sense :) ) Julian On Wed, May 27, 2009 at 7:21 PM, Pat Maddox <[hidden email]> wrote: > I changed the LoginForm component to set the account in the session > instead of using answer. Now my LoginDecoration renders the LoginForm > when there's no user in the session. > > Now I'm running into a problem with children. The LoginForm isn't in > my main component's children list...which, there's really no way it > could be - the main component doesn't know anything about the > LoginForm, it only gets created as a result of my Decoration. I > verified that this is the problem by moving all the code from my > LoginForm into my LoginDecoration, and it works fine. > > So again I think I'm doing something stupid here. I'm somewhat close > in that I can get the decoration to render my LoginForm component, but > now that component has to go into the decorated component's children > (apparently). That feels ugly so I would think there's a better way > to do this. > > Pat > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside > seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |