`bpy.ops` chaining context overrides


I’m just getting into blender source and noticed that when override a python ops context, it can not be chained to other calls or there isn’t an option to do so.

For example in the example below:

bpy.ops.foo.ops_1(override, text="print('what')")
def func():

The func() can not get the overriden context in anyway. This is specially true when func() is in bundled blender scripts or in other addons.

I checked in pyop_call it did store and restore the context dictionary for previous calls. Is there any plan to support chaining the contexts or at least expose the python override dict so other scripts can retrieve it?

Many thanks!


To elaborate on this I believe the issue I’m running into is that there’s no way in Python to change UI related fields in Context.

This is quite confusing as there’re APIs to change active selected object. And override dict actually affects all other native ops’ context as implemented in `ctx_wm_python_context_get

I’ve managed to locally patch context to be writable and it did work for me. But I assume there’s a reason for that.

Is there any prior bug related to this? Or I’m missing something very obvious.

Thanks in advance!

def func(ctx):