def _get_action_handlers(my): # get all of the element names for this asset search_type_obj = SearchType.get(my.search_type) # if element names are not specified, then get it from the view from pyasm.widget.widget_config import WidgetConfigView, WidgetConfig if not my.element_names: config = WidgetConfigView.get_by_search_type(search_type_obj, my.view) my.element_names = config.get_element_names() else: # FIXME: do we just a WidgetConfig here???? base_view = my.view config = WidgetConfigView.get_by_element_names(my.search_type, my.element_names, base_view=base_view) 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) for key,value in action_options.items(): action_handler.set_option(key, value) action_handlers.append(action_handler) return action_handlers
def _get_action_handlers(self): # get all of the element names for this asset search_type_obj = SearchType.get(self.search_type) # if element names are not specified, then get it from the view from pyasm.widget.widget_config import WidgetConfigView, WidgetConfig if not self.element_names: config = WidgetConfigView.get_by_search_type(search_type_obj, self.view) self.element_names = config.get_element_names() else: # FIXME: do we just a WidgetConfig here???? base_view = self.view config = WidgetConfigView.get_by_element_names(self.search_type, self.element_names, base_view=base_view) assert self.element_names assert config # create all of the handlers action_handlers = [] for element_name in (self.element_names): action_handler_class = \ config.get_action_handler(element_name) if action_handler_class == "": action_handler_class = self.get_default_action_handler() action_handler = WidgetConfig.create_widget( action_handler_class ) action_handler.set_name(element_name) action_handler.set_input_prefix(self.input_prefix) action_options = config.get_action_options(element_name) for key,value in action_options.items(): action_handler.set_option(key, value) action_handlers.append(action_handler) return action_handlers
def _get_action_handlers(self): from pyasm.widget.widget_config import WidgetConfig, WidgetConfigView # get all of the element names for this asset search_type_obj = SearchType.get(self.search_type) # get the sobject config default_config = WidgetConfig.get_default( \ search_type_obj,self.view) config = WidgetConfigView.get_by_search_type(search_type_obj,self.view) from pyasm.widget import EditAllWdg from pyasm.web import WebContainer element_name = WebContainer.get_web().get_form_value(\ EditAllWdg.ELEMENT_NAME) # store action handlers in a list, only getting one for now action_handlers = [] action_handler_class = \ config.get_action_handler(element_name) # else get it from the default handler if default_config != None and action_handler_class == "": action_handler_class = \ default_config.get_action_handler(element_name) if action_handler_class == "": action_handler_class = self.get_default_action_handler() action_handler = WidgetConfig.create_widget( action_handler_class ) action_handler.set_name(element_name) action_handler.set_input_prefix(self.input_prefix) action_handlers.append(action_handler) return action_handlers
def _get_action_handlers(my): from pyasm.widget.widget_config import WidgetConfig, WidgetConfigView # get all of the element names for this asset search_type_obj = SearchType.get(my.search_type) # get the sobject config default_config = WidgetConfig.get_default( \ search_type_obj,my.view) config = WidgetConfigView.get_by_search_type(search_type_obj,my.view) from pyasm.widget import EditAllWdg from pyasm.web import WebContainer element_name = WebContainer.get_web().get_form_value(\ EditAllWdg.ELEMENT_NAME) # store action handlers in a list, only getting one for now action_handlers = [] action_handler_class = \ config.get_action_handler(element_name) # else get it from the default handler if default_config != None and action_handler_class == "": action_handler_class = \ default_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_handlers.append(action_handler) return action_handlers
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(search_type_obj, my.view) 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() 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
def query_search_types_extended(project_code, namespace): """ This crazy stuff made to execute queries on server All needed info is getting almost half time faster :return: """ # TODO remove query, and dig deeper to get more info about pipelines, processes, stypes # from pyasm.search import Search # from pyasm.biz import Pipeline # # search_type = 'cgshort/scenes' # search = Search("sthpw/pipeline") # search.add_filter("search_type", search_type) # pipelines = search.get_sobjects() # # return str(pipelines) import json from pyasm.biz import Project api = server.server get_sobject_dict = api.get_sobject_dict prj = Project.get_by_code(project_code) stypes = prj.get_search_types() from pyasm.widget import WidgetConfigView from pyasm.search import WidgetDbConfig from pyasm.biz import Project all_stypes = [] for stype in stypes: stype_dict = get_sobject_dict(stype) stype_dict['column_info'] = stype.get_column_info(stype.get_code()) all_stypes.append(stype_dict) # getting views for columns viewer views = ['table', 'definition', 'color', 'edit', 'edit_definition'] definition = {} full_search_type = Project.get_full_search_type(stype) for view in views: db_config = WidgetDbConfig.get_by_search_type( full_search_type, view) if db_config: config = db_config.get_xml() else: config_view = WidgetConfigView.get_by_search_type(stype, view) config = config_view.get_config() definition[view] = config.to_string() stype_dict['definition'] = definition # getting pipeline process # stypes_codes = [] # for stype in all_stypes: # stypes_codes.append(stype['code']) # stypes_codes.append('sthpw/task') search_type = 'sthpw/pipeline' # filters = [('search_type', stypes_codes)] - THIS IS VALID CODE # filters = [('project_code', 'is', 'NULL'), ('project_code', 'like', project_code)] filters = [] # temporary stypes_pipelines = server.query(search_type, filters, return_sobjects=True) # getting processes info pipelines = [] for stype in stypes_pipelines: stypes_dict = stype.get_sobject_dict() processes = [] for process in stype.get_process_names(): process_sobject = stype.get_process_sobject(process) if process_sobject: processes.append(api.get_sobject_dict(process_sobject)) task_processes = [] for process in stype.get_processes(): process_obj = process.get_task_pipeline() if process_obj != 'task': task_processes.append(process_obj) stypes_dict['tasks_processes'] = task_processes stypes_dict['stypes_processes'] = processes pipelines.append(stypes_dict) # getting project schema schema = server.query('sthpw/schema', [('code', project_code)]) result = {'schema': schema, 'pipelines': pipelines, 'stypes': all_stypes} return json.dumps(result, separators=(',', ':'))
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