Package horizons :: Package util :: Module living :: Class livingProperty
[hide private]
[frames] | no frames]

Class livingProperty

source code

livingProperty's are used to assign properties to a class, similar to python properties.
The extra benefit with livingPropertys is, that they will call the previously assigned
instances' end() function one being replaced. Note that all classes that are assigned
to a livingProperty should subclass the LivingObject class, to ensure the existence of
the end() method.
The main purpose of the livingProperty is to ensure the correct deletion of objects,
so Classes that derive from the LivingObject class will usually have all their __del__
code in the end() method, to ensure it gets called upon being overwritten, even if
other references to it exist (which should not!).
Here is a small example on the usage:

class Livetest:
    prop1 = new livingProperty()

    def __init__(self):
        prop1 = new TestObj()
                prop1 = new Test2Obj() // TestObj().end() is called
                prop1 = new TestObj()  // Testobj2().end() is called

class TestObj(LivingProperty):
    def end():
            print "TestObj end"

class Testobj2(LivingProperty):
    def end():
            print "TestObj2 end"

This would result in the following output:
TestObj end
TestObj2 end

Instance Methods [hide private]
 
__init__(self) source code
 
__get__(self, obj, cls=None) source code
 
__set__(self, obj, value) source code
 
__delete__(self, obj) source code