Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-09-11 19:13:22 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-09-11 19:13:22 +0400
commit386bd712405c90946960718ce1460f38a1a4d9b9 (patch)
tree7f8672af54fbd2f3307912c1c56785c81a65c25b
parent38669bd5fdf703f94de1884798580e9326e00057 (diff)
pyrna: replace method for operators forwarding getattr/setattr access from self.* to self.properties.*
-rw-r--r--release/scripts/modules/bpy_types.py26
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c3
2 files changed, 18 insertions, 11 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 358628c001e..58a339d79c1 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -637,14 +637,24 @@ class OrderedMeta(RNAMeta):
# Only defined so operators members can be used by accessing self.order
class Operator(StructRNA, metaclass=OrderedMeta):
__slots__ = ()
-
- @classmethod
- def easy_getsets(cls):
- def bypass_attr(attr):
- setattr(cls, attr, property(lambda self: getattr(self.properties, attr), lambda self, value: setattr(self.properties, attr, value)))
- for attr, value in list(cls.__dict__.items()):
- if type(value) == tuple and len(value) == 2 and type(value[1]) == dict:
- bypass_attr(attr)
+
+ def __getattribute__(self, attr):
+ properties = StructRNA.path_resolve(self, "properties")
+ if attr in properties.bl_rna.properties:
+ return getattr(properties, attr)
+ return super().__getattribute__(attr)
+
+ def __setattr__(self, attr, value):
+ properties = StructRNA.path_resolve(self, "properties")
+ if attr in properties.bl_rna.properties:
+ setattr(properties, attr, value)
+ return super().__setattr__(attr, value)
+
+ def __delattr__(self, attr):
+ properties = StructRNA.path_resolve(self, "properties")
+ if attr in properties.bl_rna.properties:
+ delattr(properties, attr)
+ return super().__delattr__(attr)
class Macro(StructRNA, metaclass=OrderedMeta):
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 27da839960b..6d16896fb16 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -45,9 +45,6 @@ static void operator_properties_init(wmOperatorType *ot)
PyErr_Print(); /* failed to register operator props */
PyErr_Clear();
}
-
- // see bpy_types.py:Operator, May redo this some other way!
- PyObject_CallMethod(py_class, "easy_getsets", NULL);
}
void operator_wrapper(wmOperatorType *ot, void *userdata)