[TransWarp] how to build a dynamic component container?

Matthias Drochner M.Drochner at fz-juelich.de
Mon Aug 18 09:29:06 EDT 2003

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?

thanks and best regards

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

        axislist = binding.New(list)

        def addaxis(self, axis, name):
                binding.suggestParentComponent(self, name, axis)
                self.__setattr__(name, axis)

        def goto(self, pos, unit):
                for i in self.axislist:
                        i.goto(pos, unit)

More information about the PEAK mailing list