def _get_action_handlers(my): # get all of the element names for this asset search_type_obj = SearchType.get(my.search_type) # discover any default handlers default_elements = [] from pyasm.widget.widget_config import WidgetConfigView, WidgetConfig tmp_config = WidgetConfigView.get_by_search_type(my.search_type, my.view) tmp_element_names = tmp_config.get_element_names() for element_name in tmp_element_names: action_handler = tmp_config.get_action_handler(element_name) if action_handler == 'DefaultValueDatabaseAction': default_elements.append(element_name) # if element names are not specified, then get it from the view if not my.element_names: config = WidgetConfigView.get_by_search_type(search_type_obj, my.view) my.element_names = config.get_element_names() elif my.config_xml: config = WidgetConfigView.get_by_search_type(search_type_obj, my.view) extra_config = WidgetConfig.get(view="tab", xml=my.config_xml) config.get_configs().insert(0, extra_config) else: base_view = my.view config = WidgetConfigView.get_by_element_names(my.search_type, my.element_names, base_view=base_view) # as a back up look up the definition in the view display_view = "table" display_config = WidgetConfigView.get_by_search_type(search_type_obj, display_view) # add the default elements for element_name in default_elements: if element_name not in my.element_names: my.element_names.append(element_name) assert my.element_names assert config # create all of the handlers action_handlers = [] for element_name in my.element_names: action_handler_class = \ config.get_action_handler(element_name) # Try to get it from the display view if not action_handler_class: display_class = \ display_config.get_display_handler(element_name) try: stmt = Common.get_import_from_class_path(display_class) exec(stmt) action_handler_class = eval("%s.get_default_action()" % display_class) except Exception, e: print "WARNING: ", e action_handler_class = "" if action_handler_class == "": action_handler_class = my.get_default_action_handler() action_handler = WidgetConfig.create_widget( action_handler_class ) action_handler.set_name(element_name) action_handler.set_input_prefix(my.input_prefix) action_options = config.get_action_options(element_name) if my.data != None: element_data = my.data.get(element_name) action_handler.set_data(element_data) for key,value in action_options.items(): action_handler.set_option(key, value) action_handlers.append(action_handler)
def _get_action_handlers(my): # get all of the element names for this asset search_type_obj = SearchType.get(my.search_type) # discover any default handlers default_elements = [] from pyasm.widget.widget_config import WidgetConfigView, WidgetConfig xxconfig = WidgetConfigView.get_by_search_type(my.search_type, my.view) xxelement_names = xxconfig.get_element_names() for element_name in xxelement_names: action_handler = xxconfig.get_action_handler(element_name) if action_handler == 'DefaultValueDatabaseAction': default_elements.append(element_name) # if element names are not specified, then get it from the view if not my.element_names: config = WidgetConfigView.get_by_search_type(search_type_obj, my.view) my.element_names = config.get_element_names() elif my.config_xml: config = WidgetConfigView.get_by_search_type(search_type_obj, my.view) extra_config = WidgetConfig.get(view="tab", xml=my.config_xml) config.get_configs().insert(0, extra_config) else: base_view = my.view config = WidgetConfigView.get_by_element_names(my.search_type, my.element_names, base_view=base_view) # add the default elements for element_name in default_elements: if element_name not in my.element_names: my.element_names.append(element_name) assert my.element_names assert config # create all of the handlers action_handlers = [] for element_name in my.element_names: action_handler_class = \ config.get_action_handler(element_name) if action_handler_class == "": action_handler_class = my.get_default_action_handler() action_handler = WidgetConfig.create_widget( action_handler_class ) action_handler.set_name(element_name) action_handler.set_input_prefix(my.input_prefix) action_options = config.get_action_options(element_name) if my.data != None: element_data = my.data.get(element_name) action_handler.set_data(element_data) for key,value in action_options.items(): action_handler.set_option(key, value) action_handlers.append(action_handler) return action_handlers