diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-10 18:09:53 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-10 18:09:53 +0300 |
commit | 7efc2c2375bb591d57f6f3d63b274de48172e43b (patch) | |
tree | 5bf49f58ed3fb4cf6be8a953645d692503afc1c5 /release | |
parent | 1f2fe7ec1409298527d757cb395358bc02d494c1 (diff) |
modify the python context access so invalid names will raise an exception rather then returning None.
this way the UI scripts are less likely to fail silently and wont let typos work ok.
also allow subclassing of the context, added a copy function,
bpy.context.copy(), returns the context as a python dict to be modified and used in python.
This also showed up an invalid brush member in the screen context.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index d2bed9f7faa..23862c5c840 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -22,6 +22,17 @@ StructRNA = bpy.types.Struct.__bases__[0] # StructRNA = bpy.types.Struct +class Context(StructRNA): + + def copy(self): + new_context = {} + for item in dir(self): + if item not in StructRNA.__dict__ and item != "id_data": + new_context[item] = getattr(self, item) + + return new_context + + class Object(bpy.types.ID): def _get_children(self): |