[Seaside] ShoreComponents test cases -- worth doing?
squeak3 at continentalbrno.cz
Tue Jul 19 17:35:41 CEST 2005
There’s new version on repository which uses the first solution (parent
method). Thank you for your analysis. This may enable to use some
ShoreComponents in classical Seaside applications.
>>It’s really mainly "self check“. Every component except real root
>>should have a parent. If we will use #mustBeChild method, we loose
>>this checking functionality anyway. What about to use any nonviolent
>>way to warn the programmer (any message in Transcript etc.)?
>Hmm...then there would be lots of Transcript traffic for my test cases.
>Better than the current situation but not ideal. Also means the
>self-check isn't as in-your-face as you might want it to be (no debugger
>means it's too easily ignored and eventually will just become an
>annoyance). Is it feasible to throw an exception in #parent?
> "Returns the receivers parent component"
> ^parent ifNil: [self class canBeRoot ifFalse: [self error:
>'Component has no parent. Consider creating the instance with parent:
>instead of new.'] ifTrue: ]
>This delays the error message a bit but in cases where it _should_ occur
>it seems like it would. That is, sending #parent to a component asserts
>that it either has a parent or is allowed to be a root component,
>otherwise its an error. So, non-canBeRoot components who are parentless
>are OK until you ask them for their parent. It's a bit of a change in
>philosophy. I made this change in my image and the demos still run just
>fine. This would fix my tests since most of these components don't
>really need to be parented (they never send #parent to themselves).
>Another idea: What if the component checks to see if its class it is
>the root class of the application?
> "Returns a new instance of the receiver"
> (self canBeRoot or: [self classIsRootOfApplication])
> ifTrue: [ ^ super new ]
> ifFalse: [ self error: 'use parent:'.].
> ^(self session application preferenceAt: #rootClass) = self
>So, if the component was intentionally made the root of an application
>it is OK. Otherwise it is an error. This would catch all of the cases
>you were talking about. It seems a bit hack-ish though.
>Seaside mailing list
>Seaside at lists.squeakfoundation.org
More information about the Seaside