Clear various tables with single function

In an application we use different buttons to clear tables. I’ve tried to simplify the code by separating primary functions and one secondary function, like this:

    def clear_sls_table(self):
        self.clear_table(limit_state='service_limit_state')

    def clear_uls_table(self):
        self.clear_table(limit_state='ultimate_limit_state')

    def clear_als_table(self):
        self.clear_table(limit_state='accidental_limit_state')

    @staticmethod
    def clear_table(limit_state: str):
        new_params = {
            'load_cases': {
                limit_state: default_columns_load_input_table,
            }
        }
        return ViktorResult(set_parameters_result=SetParametersResult(new_params))

I can’t find no fault in the above mentioned code, and the application gives no error in the terminal. However, the tables aren’t cleared and the website gives the following warning:
image

The obvious workaround is to return the new_params in the clear_table method and to add a ViktorResult return in the primary functions, but this way around uses more code lines, so I was wondering why this doesn’t work.

Hi Bart,

Your methods are not returning anything. The following should work:

   def clear_sls_table(self):
        return self.clear_table(limit_state='service_limit_state')

    def clear_uls_table(self):
        return self.clear_table(limit_state='ultimate_limit_state')

    def clear_als_table(self):
        return self.clear_table(limit_state='accidental_limit_state')

    @staticmethod
    def clear_table(limit_state: str):
        new_params = {
            'load_cases': {
                limit_state: default_columns_load_input_table,
            }
        }
        return ViktorResult(set_parameters_result=SetParametersResult(new_params))

Thanks, if you see it, it is obvious :wink: