Skip to content

FunctionGlue

Source

django_glue.glue.function.glue.FunctionGlue

Bases: BaseGlue

Source code in django_glue/glue/function/glue.py
def __init__(
        self,
        unique_name: str,
        function_path: str,
):
    super().__init__(unique_name, GlueType.FUNCTION, Access.VIEW)
    self.function_path = function_path

    self.module_name = '.'.join(function_path.split('.')[:-1])
    self.function_name = function_path.split('.')[-1]

function_path = function_path instance-attribute

module_name = '.'.join(function_path.split('.')[:-1]) instance-attribute

function_name = function_path.split('.')[-1] instance-attribute

call

Source code in django_glue/glue/function/glue.py
def call(self, function_kwargs):
    module = __import__(self.module_name, fromlist=[self.function_name])

    if hasattr(module, self.function_name):
        function = getattr(module, self.function_name)

        if check_valid_method_kwargs(function, function_kwargs):
            type_set_kwargs = type_set_method_kwargs(function, function_kwargs)

            return function(**type_set_kwargs)

    return None

to_session_data

Source code in django_glue/glue/function/glue.py
def to_session_data(self) -> FunctionGlueSessionData:
    return FunctionGlueSessionData(
        unique_name=self.unique_name,
        glue_type=self.glue_type,
        access=self.access,
        function_path=self.function_path
    )

to_response_data staticmethod

Source code in django_glue/glue/function/glue.py
@staticmethod
def to_response_data(function_return) -> FunctionGlueJsonData:
    return FunctionGlueJsonData(function_return)