Index: release/scripts/modules/bpy_ops.py =================================================================== --- release/scripts/modules/bpy_ops.py (revision 24010) +++ release/scripts/modules/bpy_ops.py (working copy) @@ -155,50 +155,55 @@ rna_path_prop = bpy.props.StringProperty(attr="path", name="Context Attributes", description="rna context string", maxlen= 1024, default= "") +def getpath(obj, path): + for name in path.split('.'): + obj = getattr(obj, name) + return obj + +def setpath(obj, path, value): + path = path.split('.') + for name in path[:-1]: + obj = getattr(obj, name) + setattr(obj, path[-1], value) + +def simple_execute(self, context): + setpath(context, self.path, self.value) + return ('FINISHED',) + class WM_OT_context_set_boolean(bpy.types.Operator): '''Set a context value.''' __idname__ = "wm.context_set_boolean" __label__ = "Context Set" __props__ = [rna_path_prop, bpy.props.BoolProperty(attr="value", name="Value", description="Assignment value", default= True)] - def execute(self, context): - exec("context.%s=%s" % (self.path, self.value)) # security nuts will complain. - return ('FINISHED',) + execute = simple_execute class WM_OT_context_set_int(bpy.types.Operator): # same as enum '''Set a context value.''' __idname__ = "wm.context_set_int" __label__ = "Context Set" __props__ = [rna_path_prop, bpy.props.IntProperty(attr="value", name="Value", description="Assignment value", default= 0)] - def execute(self, context): - exec("context.%s=%d" % (self.path, self.value)) # security nuts will complain. - return ('FINISHED',) + execute = simple_execute class WM_OT_context_set_float(bpy.types.Operator): # same as enum '''Set a context value.''' __idname__ = "wm.context_set_int" __label__ = "Context Set" __props__ = [rna_path_prop, bpy.props.FloatProperty(attr="value", name="Value", description="Assignment value", default= 0.0)] - def execute(self, context): - exec("context.%s=%f" % (self.path, self.value)) # security nuts will complain. - return ('FINISHED',) + execute = simple_execute class WM_OT_context_set_string(bpy.types.Operator): # same as enum '''Set a context value.''' __idname__ = "wm.context_set_string" __label__ = "Context Set" __props__ = [rna_path_prop, bpy.props.StringProperty(attr="value", name="Value", description="Assignment value", maxlen= 1024, default= "")] - def execute(self, context): - exec("context.%s='%s'" % (self.path, self.value)) # security nuts will complain. - return ('FINISHED',) + execute = simple_execute class WM_OT_context_set_enum(bpy.types.Operator): '''Set a context value.''' __idname__ = "wm.context_set_enum" __label__ = "Context Set" __props__ = [rna_path_prop, bpy.props.StringProperty(attr="value", name="Value", description="Assignment value (as a string)", maxlen= 1024, default= "")] - def execute(self, context): - exec("context.%s='%s'" % (self.path, self.value)) # security nuts will complain. - return ('FINISHED',) + execute = simple_execute class WM_OT_context_toggle(bpy.types.Operator): '''Toggle a context value.''' @@ -206,7 +211,7 @@ __label__ = "Context Toggle" __props__ = [rna_path_prop] def execute(self, context): - exec("context.%s=not (context.%s)" % (self.path, self.path)) # security nuts will complain. + setpath(context, self.path, not getpath(context, self.path)) return ('FINISHED',) class WM_OT_context_toggle_enum(bpy.types.Operator): @@ -219,7 +224,11 @@ bpy.props.StringProperty(attr="value_2", name="Value", description="Toggle enum", maxlen= 1024, default= "") ] def execute(self, context): - exec("context.%s = ['%s', '%s'][context.%s!='%s']" % (self.path, self.value_1, self.value_2, self.path, self.value_2)) # security nuts will complain. + if getpath(context, self.path) == self.value_2: + setpath(context, self.path, self.value_1) + else: + setpath(context, self.path, self.value_2) + return ('FINISHED',) class WM_OT_context_cycle_enum(bpy.types.Operator): @@ -228,14 +237,14 @@ __label__ = "Context Enum Cycle" __props__ = [rna_path_prop, bpy.props.BoolProperty(attr="reverse", name="Reverse", description="Cycle backwards", default= False)] def execute(self, context): - orig_value = eval("context.%s" % self.path) # security nuts will complain. + orig_value = getpath(context, self.path) # Have to get rna enum values rna_struct_str, rna_prop_str = self.path.rsplit('.', 1) i = rna_prop_str.find('[') if i != -1: rna_prop_str = rna_prop_str[0:i] # just incse we get "context.foo.bar[0]" - rna_struct = eval("context.%s.rna_type" % rna_struct_str) + rna_struct = getpath(context, rna_struct_str).rna_type rna_prop = rna_struct.properties[rna_prop_str] @@ -254,7 +263,7 @@ else: advance_enum = enums[orig_index+1] # set the new value - exec("context.%s=advance_enum" % self.path) + setpath(context, self.path, advance_enum) return ('FINISHED',) bpy.ops.add(MESH_OT_delete_edgeloop) Index: release/scripts/ui/space_userpref.py =================================================================== --- release/scripts/ui/space_userpref.py (revision 24010) +++ release/scripts/ui/space_userpref.py (working copy) @@ -620,7 +620,7 @@ if props != None: for pname in dir(props): if props.is_property_set(pname) and not props.is_property_hidden(pname): - value = eval("props.%s" % pname) + value = getattr(props, pname) value = self._string_value(value) if value != "": f.write("kmi.properties.%s = %s\n" % (pname, value))