Closures not working even with fixTemps?

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

Closures not working even with fixTemps?

Sophie424
I can't get this to work right. At point 1>>, newModel is correct and
non-nil. At point 2>> newModel is nil. I'm trying this on 3.10gamma.

Thanks -- Sophie

renderNewModelButton: html
  { M1. M2 } do:
    [ : modelClass |
       html submitButton
       callback:
         [ | newModel |
           self session magma commit: [
             newModel := self repository models add: modelClass new.
1>>          self halt] fixTemps.
             self halt.
2>>          self call: (newModel viewerClass new model: newModel).
             selectedModel := nil ] fixTemps;
       value: #New , ' ' , modelClass name ]



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

Re: Closures not working even with fixTemps?

keith1y
itsme213 wrote:

> I can't get this to work right. At point 1>>, newModel is correct and
> non-nil. At point 2>> newModel is nil. I'm trying this on 3.10gamma.
>
> Thanks -- Sophie
>
> renderNewModelButton: html
>   { M1. M2 } do:
>     [ : modelClass |
>        html submitButton
>        callback:
>          [ | newModel |
>            self session magma commit: [
>              newModel := self repository models add: modelClass new.
> 1>>          self halt] fixTemps.
>              self halt.
> 2>>          self call: (newModel viewerClass new model: newModel).
>              selectedModel := nil ] fixTemps;
>        value: #New , ' ' , modelClass name ]
>
>
>  
FYI, the Automatic helpers do commit automatically any changes which
occur to the persisted data tree within callbacks.

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

Re: Closures not working even with fixTemps?

Lukas Renggli
In reply to this post by Sophie424
> renderNewModelButton: html
>   { M1. M2 } do:
>     [ : modelClass |
>        html submitButton
>        callback:
>          [ | newModel |
>            self session magma commit: [
>              newModel := self repository models add: modelClass new.
> 1>>          self halt] fixTemps.
>              self halt.
> 2>>          self call: (newModel viewerClass new model: newModel).
>              selectedModel := nil ] fixTemps;
>        value: #New , ' ' , modelClass name ]

It looks like this is indeed a bug in Squeak, as there are two blocks
that mess around and copy their home contexts.

As a first step I would put all the callback-code into a separate
method taking the modelClass as an argument. It is good practice not
to mix view (rendering) and controller (callbacks) functionality
anyway.

You don't have to send #fixTemps to the callback-block, as Seaside
already does this for you. Moreover, it is called #fixCallbackTemps
nowadays.

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: Closures not working even with fixTemps?

Sophie424
In reply to this post by keith1y
"Keith Hodges" <[hidden email]> wrote in message
>>
> FYI, the Automatic helpers do commit automatically any changes which
> occur to the persisted data tree within callbacks.

Yes, thanks Keith. Do you know if it might be possible to do the same for
Ajax calls as well? I don't know Seaside internals, but Gemstone claims to
do it for both.

- Sophie



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

Re: Re: Closures not working even with fixTemps?

keith1y
itsme213 wrote:

> "Keith Hodges" <[hidden email]> wrote in message
>  
>> FYI, the Automatic helpers do commit automatically any changes which
>> occur to the persisted data tree within callbacks.
>>    
>
> Yes, thanks Keith. Do you know if it might be possible to do the same for
> Ajax calls as well? I don't know Seaside internals, but Gemstone claims to
> do it for both.
>
> - Sophie
>
>  
Yes should be possible, just a case of spotting where to put the call to
#commitAndBegin in the framework though
I wasnt actually sure whether it would be desirable. I thought it might
slow down the ajax response too much.

However I have added the ability to seaside/WAKom to add hooks after the
server has responded to the web browser.
If I can put it in there somewhere then it would not slow down the response.

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