[Bf-python] Registry.SetKey issues

Joe Eagar joeedh at gmail.com
Sat Apr 14 03:24:39 CEST 2007


One problem we have is that the Registry is global for the entire 
blender session.  I agree with your reasons for the limitations on 
caching keys, that makes sense (now that I think about it) because these 
keys will be reloaded every time blender starts.

We could implement a way for scripts to store data in a .blend.  This 
doesn't have to be on the C side; we could make a python module that has 
generic functions for sterilizing things into a text file, then loading 
them as-needed (with support for caching stuff in the Registry). I've 
done something similar to this before.

The only issue is documentation; at the moment, the epydocs don't 
include documentation for the bpy python modules we bundle with 
blender.  Perhaps this would be worth doing, so users can more easily 
use these things.

Joe

Willian Padovani Germano wrote:
> Joe Eagar wrote:
>> Hi.  I noticed that Registry.SetKey uses an external script to save 
>> data.  This seems like a kindof odd thing to do, because it makes 
>> blender dependant on an external script (instead of the other way 
>> around).
>
> Hi, was just a test to see if it would work fine to mix things this 
> way, using Python for things it does well. Works fine and the script 
> is bundled with Blender, so only "broken" installs wouldn't have it. 
> But of course it can be rewritten in C if needed.
>
>> Also, could someone explain why there are all kinds of weird 
>> limitations on the data you can save?
>
> This system was intended for simple script config data, not for 
> general data. Since this stays in the Registry dict and depends on 
> script writers being sensible to how much to store there, a system 
> with clear goals and limitations seemed better to me.
>
>> Perhaps its to make the config editor script easier; however I think 
>> if a script wants to save more complex data, it should be able to.
>
> It is able to, you have the full power and simplicity of Python on 
> your hands, just create a file (there's the scripts/bpydata/ dir as 
> recommended place to save this file) and write whatever data you want 
> to there. You can also put any data on the Registry if you need it in 
> memory for a while.
>
>> There should be no real limit to the size of a dict, lists or 
>> strings, as its trivial to wrap long lines to prevent saving one 
>> giant line in the config file.
>
> The limitations were meant as a way to keep the system simple and to 
> the point: saving config data (for gui button states, paths, etc.), 
> nothing fancier, no "pickle for blender". For anything more complex, 
> just create your own file.
>
> Anyway, Joe, if you think this should be upgraded to support general 
> data, feel free to discuss more here (with examples of what you want 
> to do) and add it as a topic for a future meeting.
>




More information about the Bf-python mailing list