Automatic registration of children?

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

Automatic registration of children?

Nicolas Petton
Hi,

Maybe I don't know Seaside enough and the following doesn't make sense,
but just in case..

Back when I was playing around with Seaside, I always found quite
annoying to have to implement #children everywhere in my components and
feared to break the back button somewhere.

We recently needed a #children like method in Iliad, so I thought about
other ways to do it.

The idea is to use a dynamic variable (let's call it
WACurrentComponent). When rendering a component, we register can
children with something like:

renderOn: aRenderer
    self withChildrenRegistrationDo: [
        ...
        ...]

withChildrenRegistrationDo: aBlock
    children := OrderedCollection new.
    WACurrentComponent value ifNotNil: [:parent |
        parent registerChild: self].
    WACurrentComponent use: self during: aBlock

registerChild: aComponent
    children add: aComponent


As I said, it works fine for us but maybe it won't for Seaside :)

Cheers!
Nicolas

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

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Automatic registration of children?

Julian Fitzell-2
Hi Nicolas,

I've often tried to think of something like this to remove the need
for #children. The problem is that #children is used to support
#updateRoot:, #updateUrl:, both of which happen (more or less by
necessity, at least if you want to support streaming content) before
rendering.

I've thought of having maybe a dummy rendering context so you could do
a fake render pass to collect the children before doing the real
rendering. I think this would work as long as the rendering was
side-effect free (it's supposed to be anyway) but I'm not sure what
the performance overhead would be. The stream output operations would
be no-ops, but any other computation, database access, etc. would
still end up being performed a second time.

Julian

2010/8/13 Nicolas Petton <[hidden email]>:

> Hi,
>
> Maybe I don't know Seaside enough and the following doesn't make sense,
> but just in case..
>
> Back when I was playing around with Seaside, I always found quite
> annoying to have to implement #children everywhere in my components and
> feared to break the back button somewhere.
>
> We recently needed a #children like method in Iliad, so I thought about
> other ways to do it.
>
> The idea is to use a dynamic variable (let's call it
> WACurrentComponent). When rendering a component, we register can
> children with something like:
>
> renderOn: aRenderer
>    self withChildrenRegistrationDo: [
>        ...
>        ...]
>
> withChildrenRegistrationDo: aBlock
>    children := OrderedCollection new.
>    WACurrentComponent value ifNotNil: [:parent |
>        parent registerChild: self].
>    WACurrentComponent use: self during: aBlock
>
> registerChild: aComponent
>    children add: aComponent
>
>
> As I said, it works fine for us but maybe it won't for Seaside :)
>
> Cheers!
> Nicolas
>
> _______________________________________________
> seaside-dev mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>
>
_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatic registration of children?

Lukas Renggli
What about having a slow default implementation of #children that does
exactly what you describe and that can and should be overriden as we
do today to get efficent code?

Lukas

On Wednesday, August 18, 2010, Julian Fitzell <[hidden email]> wrote:

> Hi Nicolas,
>
> I've often tried to think of something like this to remove the need
> for #children. The problem is that #children is used to support
> #updateRoot:, #updateUrl:, both of which happen (more or less by
> necessity, at least if you want to support streaming content) before
> rendering.
>
> I've thought of having maybe a dummy rendering context so you could do
> a fake render pass to collect the children before doing the real
> rendering. I think this would work as long as the rendering was
> side-effect free (it's supposed to be anyway) but I'm not sure what
> the performance overhead would be. The stream output operations would
> be no-ops, but any other computation, database access, etc. would
> still end up being performed a second time.
>
> Julian
>
> 2010/8/13 Nicolas Petton <[hidden email]>:
>> Hi,
>>
>> Maybe I don't know Seaside enough and the following doesn't make sense,
>> but just in case..
>>
>> Back when I was playing around with Seaside, I always found quite
>> annoying to have to implement #children everywhere in my components and
>> feared to break the back button somewhere.
>>
>> We recently needed a #children like method in Iliad, so I thought about
>> other ways to do it.
>>
>> The idea is to use a dynamic variable (let's call it
>> WACurrentComponent). When rendering a component, we register can
>> children with something like:
>>
>> renderOn: aRenderer
>>    self withChildrenRegistrationDo: [
>>        ...
>>        ...]
>>
>> withChildrenRegistrationDo: aBlock
>>    children := OrderedCollection new.
>>    WACurrentComponent value ifNotNil: [:parent |
>>        parent registerChild: self].
>>    WACurrentComponent use: self during: aBlock
>>
>> registerChild: aComponent
>>    children add: aComponent
>>
>>
>> As I said, it works fine for us but maybe it won't for Seaside :)
>>
>> Cheers!
>> Nicolas
>>
>> _______________________________________________
>> seaside-dev mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>>
>>
> _______________________________________________
> seaside-dev mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>

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

Re: Automatic registration of children?

Julian Fitzell-2
Well, how would you know whether all the subcomponents had implemented
#children without using the slow method to find them all and check?

Julian

On Wed, Aug 18, 2010 at 2:18 PM, Lukas Renggli <[hidden email]> wrote:

> What about having a slow default implementation of #children that does
> exactly what you describe and that can and should be overriden as we
> do today to get efficent code?
>
> Lukas
>
> On Wednesday, August 18, 2010, Julian Fitzell <[hidden email]> wrote:
>> Hi Nicolas,
>>
>> I've often tried to think of something like this to remove the need
>> for #children. The problem is that #children is used to support
>> #updateRoot:, #updateUrl:, both of which happen (more or less by
>> necessity, at least if you want to support streaming content) before
>> rendering.
>>
>> I've thought of having maybe a dummy rendering context so you could do
>> a fake render pass to collect the children before doing the real
>> rendering. I think this would work as long as the rendering was
>> side-effect free (it's supposed to be anyway) but I'm not sure what
>> the performance overhead would be. The stream output operations would
>> be no-ops, but any other computation, database access, etc. would
>> still end up being performed a second time.
>>
>> Julian
>>
>> 2010/8/13 Nicolas Petton <[hidden email]>:
>>> Hi,
>>>
>>> Maybe I don't know Seaside enough and the following doesn't make sense,
>>> but just in case..
>>>
>>> Back when I was playing around with Seaside, I always found quite
>>> annoying to have to implement #children everywhere in my components and
>>> feared to break the back button somewhere.
>>>
>>> We recently needed a #children like method in Iliad, so I thought about
>>> other ways to do it.
>>>
>>> The idea is to use a dynamic variable (let's call it
>>> WACurrentComponent). When rendering a component, we register can
>>> children with something like:
>>>
>>> renderOn: aRenderer
>>>    self withChildrenRegistrationDo: [
>>>        ...
>>>        ...]
>>>
>>> withChildrenRegistrationDo: aBlock
>>>    children := OrderedCollection new.
>>>    WACurrentComponent value ifNotNil: [:parent |
>>>        parent registerChild: self].
>>>    WACurrentComponent use: self during: aBlock
>>>
>>> registerChild: aComponent
>>>    children add: aComponent
>>>
>>>
>>> As I said, it works fine for us but maybe it won't for Seaside :)
>>>
>>> Cheers!
>>> Nicolas
>>>
>>> _______________________________________________
>>> seaside-dev mailing list
>>> [hidden email]
>>> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>>>
>>>
>> _______________________________________________
>> seaside-dev mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
> _______________________________________________
> seaside-dev mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>
_______________________________________________
seaside-dev mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatic registration of children?

Lukas Renggli
On 19 August 2010 22:34, Julian Fitzell <[hidden email]> wrote:
> Well, how would you know whether all the subcomponents had implemented
> #children without using the slow method to find them all and check?

I don't understand why you would need to know that. The only change I
propose is to implement

   WAComponent>>children
      ^ WASlowlyFigureOutAllDirectChildren for: self

Everything else would continue as usual. People could override
#children as they do today.

Lukas

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

Re: Automatic registration of children?

Julian Fitzell-2
On Thu, Aug 19, 2010 at 9:42 PM, Lukas Renggli <[hidden email]> wrote:

> On 19 August 2010 22:34, Julian Fitzell <[hidden email]> wrote:
>> Well, how would you know whether all the subcomponents had implemented
>> #children without using the slow method to find them all and check?
>
> I don't understand why you would need to know that. The only change I
> propose is to implement
>
>   WAComponent>>children
>      ^ WASlowlyFigureOutAllDirectChildren for: self
>
> Everything else would continue as usual. People could override
> #children as they do today.

Ah, it hadn't occurred to me that an implementation within #children
would be doable (I was talking about at the render loop). Would that
implementation work? I guess you'd need to prevent #render: from
rendering anything that was a Presenter, wouldn't you? I suppose we
could make WARenderer>>#render: dispatch: through the RenderContext to
allow that level of control...

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