Significant differences between Continuation Class & WAContinuation Class?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Significant differences between Continuation Class & WAContinuation Class?

Paul DeBruicker
Hi

I'm trying to replicate the "Forgot your password" functionality in
SqueakSource 2 (http://www.squeaksource.com/ss2.html).  In the method
SSSendPassword >> sendPasswordToUserWithLogin: login (Pasted in below)
it uses the Continuation class.  In the beta Pharo image there is no
Continuation class.  Does WAContinuation do the same thing or should I
use something else?

The problem I'm experiencing is that if I change Continuation to
WAContinuation in the method a Url is generated and I can email it to
myself from Pharo, but when I click the link in the email I am brought
to a blank page.  I have not used Magritte in my project.  I would
readily believe that my problem has nothing to do with Continuation vs
WAContinuation but just that I haven't created anything to be rendered
at the link generated by  'self session actionUrlForContinuation: cc.'
 If thats the problem, how would I go about displaying a Component
when the link is clicked?


Thanks for any help you can provide

Paul



sendPasswordToUserWithLogin: login
        | member url |
        member := self model memberAt: login.
        member isNil ifTrue: [
                self informOnlyAdmin: 'You specified an unknown account. Please
contact the administrator.'.
                self answer ].
        member email isNil ifTrue: [
                self informOnlyAdmin: 'No e-mail address specified for this account.
Please contact the administrator.'.
                self answer ].
        member isSuperUser ifTrue: [
                self inform: 'Superusers shoud never forget their password.'.
                self answer ].
        Continuation currentDo: [ :cc |
                url := self session actionUrlForContinuation: cc.
                url := self repository rootUrl , url copyWithoutFirst.
                [ self sendMailWithUrl: url toMember: member ]
                        on: Exception
                        do: [ :error | self informOnlyAdmin: error messageText , '. Please
contact the administrator.'; answer ].
                self inform: 'An e-mail has been successfully sent to you.'.
                self answer ].
        self editMember: 'Change your password'.
        self answer

The editMember method is here:
SSComponent>>editMember: aTitleString
        | editor |
        editor := self session user asComponent
                addTitle: aTitleString;
                addValidatedForm;
                yourself.
        (self call: editor)
                ifNotNil: [ self session save ]
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Significant differences between Continuation Class & WAContinuation Class?

Lukas Renggli
> it uses the Continuation class.  In the beta Pharo image there is no
> Continuation class.  Does WAContinuation do the same thing or should I
> use something else?

Continuation was renamed at some point to WAContinuation to follow the
Seaside coding conventions. It is the same class and should have the
same behavior.

> The problem I'm experiencing is that if I change Continuation to
> WAContinuation in the method a Url is generated and I can email it to
> myself from Pharo, but when I click the link in the email I am brought
> to a blank page.  I have not used Magritte in my project.  I would
> readily believe that my problem has nothing to do with Continuation vs
> WAContinuation but just that I haven't created anything to be rendered
> at the link generated by  'self session actionUrlForContinuation: cc.'
>  If thats the problem, how would I go about displaying a Component
> when the link is clicked?

This certainly has nothing to do with Magritte. The code below looks
ok. Can you provide a minimal example (e.g. one that prints the URL to
the transcript) so that we can try to reproduce the problem.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Significant differences between Continuation Class & WAContinuation Class?

Paul DeBruicker
Thanks Lukas.  Sorry for the delayed response.


>> The problem I'm experiencing is that if I change Continuation to
>> WAContinuation in the method a Url is generated and I can email it to
>> myself from Pharo, but when I click the link in the email I am brought
>> to a blank page.  I have not used Magritte in my project.  I would
>> readily believe that my problem has nothing to do with Continuation vs
>> WAContinuation but just that I haven't created anything to be rendered
>> at the link generated by  'self session actionUrlForContinuation: cc.'
>>  If thats the problem, how would I go about displaying a Component
>> when the link is clicked?
>
> This certainly has nothing to do with Magritte. The code below looks
> ok. Can you provide a minimal example (e.g. one that prints the URL to
> the transcript) so that we can try to reproduce the problem.
>
I figured as much regarding Magritte, I just mentioned it because
SqueakSource 2 depends on it and was unsure about whether my not
having it installed was causing problems in something I was copying
from SqueakSource 2.


I've attached and pasted in a fileout of a class that prints a Url to
the transcript and shows it in an inform:  I would like to know how/
understand how to make a component appear once the link is followed
rather than a blank page.

Thanks again
Paul




WAComponent subclass: #PDMain
       
instanceVariableNames: ''
       
classVariableNames: ''
        poolDictionaries: ''
       
category: 'PADScratch'!



!PDMain methodsFor: 'as yet unclassified' stamp: 'PaulDeBruicker
9/8/2009 12:56'!


generateUrl

|url|


WAContinuation currentDo: [ :cc |

                url := self session actionUrlForContinuation: cc.
                url :=  url asString .

                Transcript show: url.

                self inform: 'The url is: ' , url.

                ].! !



!PDMain methodsFor: 'as yet unclassified' stamp: 'PaulDeBruicker
9/8/2009 12:50'!

renderContentOn: html


        html render: 'Click the button to generate a continuation Url'.

        html form

                with:[
       
                html submitButton

                        callback: [self generateUrl.];

                                with: 'Go'.

                        ]! !



"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!


PDMain class

        instanceVariableNames: ''!



!PDMain class methodsFor: 'as yet unclassified' stamp: 'PaulDeBruicker
9/8/2009 12:55'!


canBeRoot


        ^true.! !



!PDMain class methodsFor: 'as yet unclassified' stamp: 'PaulDeBruicker
9/8/2009 12:54'!


initialize

        "

        PDMain initialize

        "



        super initialize.

       (WAAdmin register: self asApplicationAt: 'Scratch')

  ! !

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

PADScratch.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Significant differences between Continuation Class & WAContinuation Class?

Lukas Renggli
I don't think that SqueakSource2 works in Seaside 3.0.

> !PDMain class methodsFor: 'as yet unclassified' stamp: 'PaulDeBruicker
> 9/8/2009 12:54'!
>
>
> initialize
>
>        "
>
>        PDMain initialize
>
>        "
>
>
>
>        super initialize.
>
>       (WAAdmin register: self asApplicationAt: 'Scratch')

You should never call super initialize on the class side, only on the
instance side.

I've tried the code in Seaside 2.8 where it works without problems.

The thing in Seaside 3.0 is that we do not use full-continuations
anymore, but partial ones. Thus if you capture a full continuation
this includes everything including the response handlers, the server
and response socket. So if you restore a full continuation you'll also
write the response to an old socket that is not valid anymore. More
information on this you find in the following blog post of Julian:
<http://blog.fitzell.ca/2009/01/seaside-partial-continuations.html>.

In fact to solve your problem no knowledge of continuations is needed.
The problem can be solved much simpler. I guess the original author
just wanted to write smart code :-)

renderContentOn: html
        html render: 'Click the button to generate a continuation Url'.
        html form: [
                html submitButton
                        callback: [ self generateUrlOn: html ];
                        with: 'Go' ]

generateUrlOn: html
        | url |
        url := html context actionUrl
                withParameter: (html callbacks
                        store: (WAActionCallback on: [ self inform: 'Got Me' ])).
        Transcript show: url asString.
        self inform: 'The url is: ' , url asString

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Significant differences between Continuation Class & WAContinuation Class?

Paul DeBruicker
On Tue, 2009-09-08 at 21:15 +0200, Lukas Renggli wrote:

> renderContentOn: html
> html render: 'Click the button to generate a continuation Url'.
> html form: [
> html submitButton
> callback: [ self generateUrlOn: html ];
> with: 'Go' ]
>
> generateUrlOn: html
> | url |
> url := html context actionUrl
> withParameter: (html callbacks
> store: (WAActionCallback on: [ self inform: 'Got Me' ])).
> Transcript show: url asString.
> self inform: 'The url is: ' , url asString

OK but if I change the generateUrlOn: html to

generateUrlOn: html
        | url |
        url := html context actionUrl
                withParameter: (html callbacks
                        store: (WAActionCallback on: [ hmtl render: 'Got
Me' ])).
        Transcript show: url asString.
        self inform: 'The url is: ' , url asString

When I access the link I get this error:

MessageNotUnderstood: receiver of "print:" is nil

So I still do not know/understand how to display a component when the
created link is clicked.  What do I change to do that?  I've tried
several combinations of things that create different errors.

Thanks

Paul  

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Significant differences between Continuation Class & WAContinuation Class?

Julian Fitzell-2
On Wed, Sep 9, 2009 at 8:59 PM, Paul DeBruicker <[hidden email]> wrote:

> On Tue, 2009-09-08 at 21:15 +0200, Lukas Renggli wrote:
>
>> renderContentOn: html
>>       html render: 'Click the button to generate a continuation Url'.
>>       html form: [
>>               html submitButton
>>                       callback: [ self generateUrlOn: html ];
>>                       with: 'Go' ]
>>
>> generateUrlOn: html
>>       | url |
>>       url := html context actionUrl
>>               withParameter: (html callbacks
>>                       store: (WAActionCallback on: [ self inform: 'Got Me' ])).
>>       Transcript show: url asString.
>>       self inform: 'The url is: ' , url asString
>
> OK but if I change the generateUrlOn: html to
>
> generateUrlOn: html
>        | url |
>        url := html context actionUrl
>                withParameter: (html callbacks
>                        store: (WAActionCallback on: [ hmtl render: 'Got
> Me' ])).
>        Transcript show: url asString.
>        self inform: 'The url is: ' , url asString
>
> When I access the link I get this error:
>
> MessageNotUnderstood: receiver of "print:" is nil

When the callback is evaluated, you are in a new request and the
renderer pointed to by html is thus no longer valid.

> So I still do not know/understand how to display a component when the
> created link is clicked.  What do I change to do that?  I've tried
> several combinations of things that create different errors.

"self call: aComponent" (or "self show: aComponent" since you don't
need the control flow to return back to the callback afterwards).
That's all #inform: does if you trace its implementation.

Julian
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside