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>2009-11-18 11:40:18 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-18 11:40:18 +0300
commit318e9aa5d10ddeca60f838d564ce0da829233771 (patch)
treedac336b034bd04a8a63d5031ee9ab4ddf114fbd5 /source/blender/python
parent1e1a0078da2e5c1c70ad881d1a45b5e0553a1424 (diff)
- rna attribute setting problem, class instances could not set their own attributes because they are blocked by our own internal setattr.
this could be supported again easily however it leads typo's & api changes not showing any errors. This broke povray export. Solution for now is to allow setting private properties starting with '_' eg, ob = bpy.context.object ob._foo = [1,2,3] # this is a python list, it will stay only as long as this PyObject is active ob.foo = 1 # raises an error!, only for rna properties ob["foo"] = 1 # converts to an ID property and is saved using the underscore like this should really be used for classes internally. - povray failed on armatures - menu key wasn't using WM_keymap_add_menu
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 4e11da8c2cb..024473f596a 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -1625,11 +1625,10 @@ static int pyrna_struct_setattro( BPy_StructRNA *self, PyObject *pyname, PyObjec
if (prop==NULL) {
// XXX - This currently allows anything to be assigned to an rna prop, need to see how this should be used
// but for now it makes porting scripts confusing since it fails silently.
-#if 0
- if (!BPy_StructRNA_CheckExact(self) && PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) {
+ // edit: allowing this for setting classes internal attributes.
+ if (name[0]=='_' && !BPy_StructRNA_CheckExact(self) && PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) {
return 0;
} else
-#endif
{
PyErr_Format( PyExc_AttributeError, "StructRNA - Attribute \"%.200s\" not found", name);
return -1;