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

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

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