On Thu, Sep 9, 2010 at 12:18 AM, Alex Fraser <[email protected]> wrote: > Hi Campbell, > > On Thu, Sep 9, 2010 at 9:18 AM, Campbell Barton <[email protected]> wrote: >> --- Proposed solution >> >> Follow the way operators work, treat properties as class attributes so... >> bpy.types.Scene.BoolProperty(attr="myprop") >> bpy.types.Scene.RemoveProperty(attr="myprop") >> ...is replaced by >> bpy.types.Scene.myprop = bpy.props.BoolProperty() >> del bpy.types.Scene.myprop > > It is certainly less verbose, but didn't we recently move away from > treating properties as attributes in the BGE? For consistency, maybe > it should be: > > bpy.types.Scene["myprop"] = bpy.props.BoolProperty() > del bpy.types.Scene["myprop"] > > On the other hand, using attributes might be better if properties are > more formally defined than in the BGE. > > Cheers, > Alex
in fact the BGE and 2.5 rna api are the same in this way. Both allow defining user properties via dictionary like syntax, this bypasses the rna api. obj["someprop"] = "Value" But the BGE doesnt have a way to extend the the internal types (beyond typical python subclassing) as we do with RNA so I dont think theres a conflict here. assigning attributes to a class works in pure python too, eg. >>> class Foo: ... pass ... >>> Foo.MyProp = property(lambda self: "Hello World") >>> >>> inst = Foo() >>> print(inst.MyProp) Hello World So you can see that assigning properties this way is in keeping with the rest of python. The main problem is that we now need to override the setattr/getattr/delattr using a metaclass and make a special exception when a blender property is assigned, looking into this now. _______________________________________________ Bf-committers mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-committers
