Skip to content
Snippets Groups Projects
Commit 365182a5 authored by Podosochnyy Maxim's avatar Podosochnyy Maxim
Browse files

Добавлена поддержка действий

parent 278accc9
No related branches found
No related tags found
1 merge request!62Добавлена поддержка действий
......@@ -66,7 +66,7 @@ class Servicer(ExtensionService):
)
]
async def demo_action_items(
async def action_demo_action_items(
self,
request: extension_pb2.ActionRequest,
context
......@@ -91,7 +91,7 @@ class Servicer(ExtensionService):
msg=f"{'Ошибка' if with_error else 'ОК'} ({request.item_ids}, {request.collection_id})"
)
async def demo_action_item(
async def action_demo_action_item(
self,
request: extension_pb2.ActionRequest,
context
......
......@@ -278,14 +278,16 @@ class ExtensionService(
) -> extension_service_pb2.ActionResponse:
action_id = request.action.split("/")[-1]
if not hasattr(self, action_id):
func_name = f"action_{action_id}"
if not hasattr(self, func_name):
response = extension_service_pb2.ActionResponse(
state=extension_service_pb2.ActionResponse.State.ERROR,
title="Невозможно выполнить действие",
error=f"В расширении отсутсвует функция {action_id}"
)
else:
func = getattr(self, action_id)
func = getattr(self, func_name)
response = await func(request, context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment