[TransWarp] how to build a dynamic component container?

Phillip J. Eby pje at telecommunity.com
Mon Aug 18 12:47:33 EDT 2003


At 03:29 PM 8/18/03 +0200, Matthias Drochner wrote:

>another basic component binding question, related to my previous
>mail about component paths...
>
>To group axes to logical units which look like an axis again
>to the outside (the "Imovable" interface in my code samples),
>I'm trying to keep the child axes within a list.
>Unfortunately this breaks all the automatic component path
>creation and lookup, so the container has to add the hooks
>by itself - see the appended code snippet for what my limited
>understanding has lead to.
>
>Is this a proper way of doing that? The "__setattr__" in
>addaxis() causes an object namespace pollution which might even
>be dangerous - is there an easy way to do it differently?

Yes, if the overall component structure is stable; i.e., doesn't change 
once you've got it set up.  Instead of using addaxis, just configure the 
axisgroup to have its axes set at construction time via a keyword argument, 
or using ZConfig thusly:

<AxisGroup>

     <Axis A>
     ...
     </Axis>

     <Axis B>
     ...
     </Axis>

     ...
</AxisGroup>



>class axisgroup(binding.Component):
>         __implements__ = [movable.Imovable]

FYI, __implements__ doesn't work for PEAK interfaces, only Zope or Twisted 
interfaces.  However, using protocols.advise() will work with all three.




More information about the PEAK mailing list