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>2011-01-27 09:48:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-27 09:48:14 +0300
commit45fc5908353e27161b4e1d536631e734f2f65ead (patch)
tree1e8da8a1d379db683147d6032682239c011de023 /source/blender
parent18aece4424f29b7d560373843fd41002862aa575 (diff)
internal changes, script writers won't notice.
disable getattr metaclass forwarding attributes from the python class, eg: bpy.types.Scene.foo != bpy.types.Scene.bl_rna.properties['foo'] ... This was convenient but too tricky to properly maintain with attribute assignment and attributes defined within the class. avoid doubles in dir() by converting to a set and then back to a list.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/python/intern/bpy_rna.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 217d0c9e1bf..b8a448106f9 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -2706,6 +2706,18 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self)
BLI_freelistN(&lb);
}
+
+ {
+ /* set(), this is needed to remove-doubles because the deferred
+ * register-props will be in both the python __dict__ and accessed as RNA */
+
+ PyObject *set= PySet_New(ret);
+
+ Py_DECREF(ret);
+ ret= PySequence_List(set);
+ Py_DECREF(set);
+ }
+
return ret;
}
@@ -2835,7 +2847,15 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
{
PyObject *ret= PyType_Type.tp_getattro(cls, attr);
- if(ret == NULL) {
+ /* Allows:
+ * >>> bpy.types.Scene.foo = BoolProperty()
+ * >>> bpy.types.Scene.foo
+ * <bpy_struct, BooleanProperty("foo")>
+ * ...rather then returning the defered class register tuple as checked by pyrna_is_deferred_prop()
+ *
+ * Disable for now, this is faking internal behavior in a way thats too tricky to maintain well. */
+#if 0
+ if(ret == NULL) { // || pyrna_is_deferred_prop(ret)
StructRNA *srna= srna_from_self(cls, "StructRNA.__getattr__");
if(srna) {
PropertyRNA *prop= RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr));
@@ -2847,6 +2867,7 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
}
}
}
+#endif
return ret;
}
@@ -2869,8 +2890,15 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
if(value) {
/* check if the value is a property */
if(pyrna_is_deferred_prop(value)) {
- /* dont add this to the __dict__, getattr deals with returning the newly created RNA_Property type */
- return deferred_register_prop(srna, attr, value);
+ int ret= deferred_register_prop(srna, attr, value);
+ if(ret == -1) {
+ /* error set */
+ return ret;
+ }
+
+ /* pass through and assign to the classes __dict__ as well
+ * when the value isn't assigned it still creates the RNA property
+ * but gets confusing from script writers POV if the assigned value cant be read back. */
}
else {
/* remove existing property if its set or we also end up with confusement */