[Bf-committers] parsing Blender and math expressions?

Theo de Ridder theo.de.ridder at planet.nl
Sun May 2 12:59:41 CEST 2010


On 2 mei 2010, at 12:00, bf-committers-request at blender.org wrote:

> Hi Theo, This could work very nicely, it could be exposed to
> bpy_driver.c as a single C function which analizes the compiled
> bytecode. Once this is done it could also be used for other areas of
> python in blender. Though I imagine it would need to disable import,
> exec and related functions.
> 
> So basically if someone wants to expose C function for this (even if
> its C calling python to start with), this could be an acceptable
> solution.


Campbell,
Nice, you picked up my suggestion, and I am willing to work on yours.
But I need some help (where to look about the current ideas and
examples of different types of (driver)scripts)
because I am looking at blender(2.5) again just recently. I am playing
now a bit with operators (very nice having direct interactiveness through
keyboard and mouse during animation and being able to change an animation
on the fly, so my old dream of using isight camera and wiiremote for modeling
comes back!)

What I saw there is a style now using the 'if __main__'  but its remains
unclear when this has to be used. In general it is a very good idea to
to do potential damaging things only through declared python functions
so that imports remain relative innocent (with holes of course through
decorators and (meta)class bodies, executed during import). Then
security control can have 2 levels: the first after compiling, the second
after importing (to do static analysis of propagation of what is in the global
namespace) and handle what is allowed a bit more subtle than deny everything. 

Checking results of 'eval' is an order of magnitude simpler, but there remain
potential nasty side-effects of pure expressions, for example through the
builtins setattr and setitem and hided shapes of them.

~Theo



More information about the Bf-committers mailing list