[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34523] trunk/blender/source/blender/ python/intern/bpy_rna.c: internal changes, script writers won't notice.
Campbell Barton
ideasman42 at gmail.com
Thu Jan 27 07:48:15 CET 2011
Revision: 34523
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34523
Author: campbellbarton
Date: 2011-01-27 06:48:14 +0000 (Thu, 27 Jan 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2011-01-27 03:37:10 UTC (rev 34522)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2011-01-27 06:48:14 UTC (rev 34523)
@@ -2706,6 +2706,18 @@
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 @@
{
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 @@
}
}
}
+#endif
return ret;
}
@@ -2869,8 +2890,15 @@
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 */
More information about the Bf-blender-cvs
mailing list