[TransWarp] dynamic class binding

alexander smishlajev alex at ank-sia.com
Mon Mar 31 14:46:42 EST 2003


hello!

please consider the following wrong code example:

    from peak.api import binding

    class A(binding.Component):
        name = "A"
        spam = binding.bindToProperty(name + ".spam",
            default=("beacon and " + name))
        def getit(self):
            print repr(self.spam)

    class B(A):
        name = "B"

    if __name__ == "__main__":
        B().getit()

the intent was to have the 'spam' property of Component 'B' bound to the 
config setting 'B.spam' and defaulting to string 'beacon and B'.

obviously, this approach does not work.

what is the right way to do such things in PEAK?

best wishes,
alex.





More information about the PEAK mailing list