[Seaside] seaside by example RPN example

Nicolai Hess nicolaihess at gmail.com
Sun Dec 18 12:27:53 UTC 2016


2016-12-16 22:06 GMT+01:00 Nicolai Hess <nicolaihess at gmail.com>:

>
>
> 2016-12-15 14:46 GMT+01:00 Nicolai Hess <nicolaihess at gmail.com>:
>
>> Hi,
>>
>> anyone knows the seaside example from the pharo by example book:
>>
>> SBE2-SeasideRPN-on.1
>>
>> MCSqueaksourceRepository
>>     location: 'http://www.squeaksource.com/SqueakByExample'
>>     user: ''
>>     password: ''
>>
>> I can not get it to work. On Seaside 3.0 you need to change the class
>> initialization,
>> because the application registration had changed.
>> But despite that, the calculator does not work. Everytime I push on a
>> number
>> I get a empty-collection-error.
>> I don't understand why, because the rendering of the calculator stack
>> calls a method ensureStackMachineNotEmpty, that puts a 0 onto the stack.
>> Now, pushing a keypad button for a number, will pop this element and
>> convert both
>> the existing number and the new number to a new number.
>> But somehow the stack is empty, eventhough we call
>> ensureStackMachineNotEmpty.
>>
>> Anyone has experience with this example or can find out what is wrong ?
>> I don't have much experience with seaside.
>>
>> thanks in advance.
>>
>
> Ah, on seaside 3.0 the current (initial state) of the StackMachine is
> saved once before the rendering (WASnapshot), and if we modify the stack
> machine state (the OrderedCollection)
> during #renderContentsOn:, the prior state (with the empty stack) is
> restored before executing the callbacks.
> This had changed, in seaside 2.8, saving the state snapshots happens first
> after the initial rendering.
> Was this change on purpose ? Is there some information about, when it is
> allowed to modify the state during rendering ?
>
> I guess we may have to make sure that any state changes are happening
> outside of the rendering, is there some ~pattern~ to follow, when it is
> save to change states ?
>
> thanks in advance
>
> nicolai
>
>

Ok I found a hint in
http://book.seaside.st/book/fundamentals/anchors/about-callbacks
"Important : Do not change state while rendering....."

Ok, so the old RPNCalculator example does not work anymore if we try to
"ensure the stack is not empty" during then renderContentsOn: method.
Now I need to find a way to ensure the stackmachine non-emptyness before
doing the rendering.

Is there a hook, called before the rendering, that *can* change the
component state ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/seaside/attachments/20161218/f257dcd1/attachment.html>


More information about the seaside mailing list