[Bf-python] shared properties?

Yann Vernier yann at algonet.se
Mon Jun 23 13:09:30 CEST 2003


When testing exppython I ran into the issue that the new Object
implementation didn't have the name attribute. While it's trivial to fix
by putting the same code there as we have for Images etc, I think
there's too much duplication there. This attribute comes straight from
the ID structure, shared by most things we're wrapping.

It seems the easiest way to implement a shared version would be to have
an ID_getattr and ID_setattr function, which would be called from each
other [sg]etattr, something like:

PyObject *attr=ID_getattr(&self->object->id, name);
if(attr) return attr;

However, it seems there's some sort of policy to have separate setName
and getName functions. Those would need to be put in the method table,
which means two extra functions for every attribute. The getattr()
variant could even be dir()-compatible; if you see the name
"__members__", add your own to the list returned. Right now some
types don't implement __members__ so only methods show up. 

I'm not sure how much of the old API has [sg]etName() functions that
work. If I'm not mistaken they failed to work on meshes and objects
(even the argument for New() was uniplemented). Could someone explain to
me why the method interface is necessary?

-- 
PGP fingerprint = 9242 DC15 2502 FEAB E15F  84C6 D538 EC09 5380 5746
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20030623/f23917eb/attachment.sig>


More information about the Bf-python mailing list