controller

ControllerMethodType

Inherits from: Enum


ctrl_method

ctrl_method(method_type: ControllerMethodType, group: str)

Decorator to define a Controller method


ctrl_cmd_method

ctrl_cmd_method(func)

Decorator to define a command method in a Controller.


ctrl_query_method

ctrl_query_method(func)

Decorator to define a query method in a Controller.


Controller

Inherits from: ABC


Methods

get_controller_method_groups

get_controller_method_groups(cls)

List of controller method types in this controller.


get_controller_methods

get_controller_methods(
   cls,
   method_type: ControllerMethodType|None,
   group: str|None
)

List of controller methods in this controller.


class FooController(Controller):
    @ctrl_cmd_method
    def bar(self):
        pass
    
    @ctrl_query_method
    def baz(self, x: int) -> str:
        pass
    
    @ctrl_method(ControllerMethodType.QUERY, "q")
    def qux(self):
        pass
    
assert FooController.get_controller_method_groups() == ['cmd', 'query', 'q']
assert FooController.get_controller_methods() == ['bar', 'baz', 'qux']
assert FooController.get_controller_methods(group='cmd') == ['bar']
assert FooController.get_controller_methods(method_type=ControllerMethodType.COMMAND) == ['bar']
assert FooController.get_controller_methods(method_type=ControllerMethodType.QUERY) == ['baz', 'qux']
assert FooController.get_controller_methods(group='query') == ['baz']
assert FooController.get_controller_methods(group='q') == ['qux']