[Bf-python] Initialization of data and python vars.
Campbell Barton
cbarton at metavr.com
Wed Aug 11 04:31:54 CEST 2004
Hi, While writing the class vars for the oops objects I discovered that
the oops data was not initialized until the oops window was viewed.
This is aparently the same with all window types (-Theeth)
The result was that Blender crashed if I asked for the data.
I solved the issue by checking if the data was there and if not
returning None, I found later this this is the prefered method (Theeth
again)
Returning None from some functions was a pain since some of them treat
the return Value None as there being an incorrect class var name.
I had to do a premature return that wasnt in keeping with the getAttr
function but ended up working.
Also the extra linus needed for returning None make the code a bit bulky
when it will rarely be used. (or checked even by a python coder)
My Proposal is that there is no checking or returning of None, just that
the python coder calls a function that initialized the data before he
tries to accsess it.
1) Add a special python call to initialize the window type.
2) Change the window to the required window type to initialize the date
(the python coder can change it back instantly (mabe without a redraw if
possibe))
This would make the code cleaner, the python programmer could always
count on the data being available (just initialize it 1st) rather then
having to deal with a None value and bail out of the script.
- Cam
--
Campbell J Barton
133 Hope Street
Geelong West, Victoria 3218 Australia
URL: http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241
More information about the Bf-python
mailing list