fix(hooks): handle dict-key bracket notation in set_value / get_value
The Hook API previously rejected key strings like 'show_windows["Project Settings"]' (and silently returned None on get). The test_live_gui_filedialog_regression test exercises exactly this pattern to open the Project Settings window via the Hook API; it was previously marked skip with "hook server doesn't handle the dict-key bracket-notation syntax". Fix in three small places: 1. src/app_controller.py:_handle_set_value If `item` is not in _settable_fields, try parsing it as `dict_name[<key>]` notation. If dict_name IS in _settable_fields and the current attr is a dict, set the inner key. 2. src/api_hooks.py:/api/gui/value (POST get_val) Mirror the parsing for the field-based get endpoint. 3. src/api_hook_client.py:ApiHookClient.get_value Mirror the parsing in the client so the dict-key syntax works through the state endpoint as well (which is what get_value actually calls by default). Test fix: - tests/test_live_gui_filedialog_regression.py: removed the @pytest.mark.skip marker; the underlying issue is now fixed. Verified: 1/1 test passes (previously skipped).
This commit is contained in:
@@ -464,6 +464,14 @@ class HookHandler(BaseHTTPRequestHandler):
|
||||
if field_tag in settable:
|
||||
attr = settable[field_tag]
|
||||
result["value"] = _serialize_for_api(_get_app_attr(app, attr, None))
|
||||
elif "[" in field_tag and field_tag.endswith("]"):
|
||||
dict_name, _, key_part = field_tag.partition("[")
|
||||
key = key_part[:-1].strip().strip("'\"")
|
||||
if dict_name in settable:
|
||||
attr = settable[dict_name]
|
||||
current = _get_app_attr(app, attr, None)
|
||||
if isinstance(current, dict) and key in current:
|
||||
result["value"] = _serialize_for_api(current[key])
|
||||
finally: event.set()
|
||||
lock = _get_app_attr(app, "_pending_gui_tasks_lock")
|
||||
tasks = _get_app_attr(app, "_pending_gui_tasks")
|
||||
|
||||
Reference in New Issue
Block a user