[Seaside] Re: Broken Seaside on SqueakMap

Nevin Pratt nevin at smalltalkpro.com
Wed Jul 2 19:43:42 CEST 2003



Avi Bryant wrote:

>On Mon, 30 Jun 2003, Stephen Pair wrote:
>
>  
>
>>It would be good to have a couple SUnit tests to cover this so that it
>>doesn't slip through again in the future.
>>    
>>
>
>It seems to have been a documentation bug - harder to write SUnit tests
>for those ;).
>
>
>  
>

Not so fast, there :-)

I'm not using #renderOn: like Todd was. I use #renderContentOn:, and am 
getting the problem.  But, I haven't yet tried the Seaside2.3b4.st 
snapshot, either (been too busy).  I don't know if you care, but here is 
what I am doing from my main component (an instance of BBIndex):

*******************************************

Here is my #renderContentOn: method:
******
renderContentOn: html
    | sel |
    sel _ self session entryPoint asLegalSelector asSymbol.
    (lastEntryPoint ~= sel
            and: [EntryPoints includes: sel])
        ifTrue: [lastEntryPoint _ sel.
            self perform: sel].
    html break.
    html render: self embed.
    html break; break
******

The 'embed' instance variable (accessed via 'self embed') gets 
initialized thus (you can see it is wrapped in a WAStateHolder):
******
initialize
    super initialize.
    embeds _ Dictionary new.
    embed _ WAStateHolder new.
    self session topComponent: self.
    self home.
    header _ BBHeader new.
    footer _ BBFooter new
******
('self session' returns an instance of BBSession, which adds the top 
component ivar, plus a shopping cart, to the standard WASession)


And here is the #embed method:
******
embed
    ^ embed contents
******

You'll notice that in #renderContentOn:, I allow various "entry points" 
into the program.  The 'EntryPoints' variable is a class variable that 
has a collection of symbols, each symbol representing an allowable 
"entry point" (I control it that way as to eliminate the possibility of 
someone being able to execute arbitrary methods via the URL).

Each "entry point" thus defined is a method (which I happen to have all 
grouped together under the method category called 'actions').  A typical 
'actions' method thus defined is implemented something like this:
******
home
    ^ embed
        contents: (embeds
                at: #home
                ifAbsentPut: [BBHome new])
******

And, each of the other components (such as BBHome, BBFeatures, etc.) 
also use #renderContentOn:

So from the above, you can also see the simple component caching scheme 
I have.  You can also see that whenever the code anywhere else wants a 
new page rendered, it just tells the topComponent (accessable from the 
session) what to render.  For example, to go back to the home page, it 
would send 'self session topComponent home'.  Or, to go to the Special 
Features page, it would send 'self session topComponent features'.  The 
#features method is an action method implemented similarly to the #home 
method, but here is the actual implementation:
*******
features
    ^ embed
        contents: (embeds
                at: #features
                ifAbsentPut: [BBFeatures new])
*******

And, you can now also see how/why I rarely do a #call:.

Anyway, I'll try your newer snapshot, but probably after I port Glorp 
again.  But it will be "Real Soon Now".

Nevin

P.S. One of our "Bountiful Baby" babies was just used in a short film, 
"Sit Down. Stand Up."-- an as-yet unreleased film produced by Film 
Festival Award Winner "Gates Bradley".  And another one was recently 
used by "Global Dolls Corp" in an advertising compaign they just 
launched-- a recent ad example is in the September edition of "Doll 
Crafters" magazine.  So, our site is starting to get some worldwide 
recognition.  And, it is pure Smalltalk (Squeak/Seaside/Comanche/Glorp 
to PostgreSQL).  I think I need to try to spruce the site up some more 
so as to make Smalltalk look as good as possible.  But it's been very busy.

-- 
Nevin Pratt
Bountiful Baby
http://www.bountifulbaby.com
(801) 992-3137





More information about the Seaside mailing list