Beispiel #1
0
def query_EditWdg(args=None, search_type=''):
    import json
    from pyasm.widget.widget_config import WidgetConfigView

    def pop_classes(in_dict):
        out_dict = {}
        for key, val in in_dict.iteritems():
            if not (hasattr(val, '__dict__') or key.startswith('_')):
                out_dict[key] = val
        return out_dict

    class_name = 'tactic.ui.panel.EditWdg'

    args_array = []

    from pyasm.common import Common

    # from pyasm.common import Container
    widget = Common.create_from_class_path(class_name, args_array, args)
    widget.explicit_display()
    result_dict = {
        'EditWdg': {
            'element_descriptions': widget.element_descriptions,
            'element_names': widget.element_names,
            'element_titles': widget.element_titles,
            'input_prefix': widget.input_prefix,
            'kwargs': widget.kwargs,
            'mode': widget.mode,
            'security_denied': widget.security_denied,
            'title': widget.title,
        },
        'InputWidgets': [],
        'sobject': '',
    }
    input_widgets = widget.get_widgets()
    wdg_config = WidgetConfigView.get_by_element_names(search_type,
                                                       widget.element_names,
                                                       base_view=args['view'])

    temprorary_ignore = ['pyasm.prod.web.prod_input_wdg.ProjectSelectWdg']
    # , 'pyasm.widget.input_wdg.SelectWdg' bug with this widget

    for i_widget in input_widgets:
        widget_dict = pop_classes(i_widget.__dict__)
        # for wv, wi in widget_dict.items():
        #     if type(wi) not in [dict, None, str, int, bool, list, set, tuple]:
        #         widget_dict[wv] = str(wi)
        widget_dict['action_options'] = wdg_config.get_action_options(
            widget_dict.get('name'))
        widget_dict['class_name'] = i_widget.get_class_name()
        item_values = i_widget.get_values()
        if item_values:
            widget_dict['values'] = item_values
        if widget_dict['class_name'] not in temprorary_ignore:
            result_dict['InputWidgets'].append(widget_dict)

    return json.dumps(result_dict, separators=(',', ':'))
def query_EditWdg(args=None, search_type=''):
    import json
    from pyasm.widget.widget_config import WidgetConfigView

    def pop_classes(in_dict):
        out_dict = {}
        for key, val in in_dict.iteritems():
            if not (hasattr(val, '__dict__') or key.startswith('_')):
                out_dict[key] = val
        return out_dict

    class_name = 'tactic.ui.panel.EditWdg'

    args_array = []

    from pyasm.common import Common

    # from pyasm.common import Container
    widget = Common.create_from_class_path(class_name, args_array, args)
    widget.explicit_display()
    result_dict = {
        'EditWdg': {
            'element_descriptions': widget.element_descriptions,
            'element_names': widget.element_names,
            'element_titles': widget.element_titles,
            'input_prefix': widget.input_prefix,
            'kwargs': widget.kwargs,
            'mode': widget.mode,
            'security_denied': widget.security_denied,
            'title': widget.title,
        },
        'InputWidgets': [],
        'sobject': '',
    }
    input_widgets = widget.get_widgets()
    wdg_config = WidgetConfigView.get_by_element_names(search_type, widget.element_names, base_view=args['view'])
    for i_widget in input_widgets:
        widget_dict = pop_classes(i_widget.__dict__)
        widget_dict['action_options'] = wdg_config.get_action_options(widget_dict.get('name'))
        widget_dict['class_name'] = i_widget.get_class_name()
        item_values = i_widget.get_values()
        if item_values:
            widget_dict['values'] = item_values
        result_dict['InputWidgets'].append(widget_dict)

    return json.dumps(result_dict, separators=(',', ':'))
Beispiel #3
0
    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
Beispiel #4
0
    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
Beispiel #5
0
    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
Beispiel #6
0
    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)
Beispiel #7
0
    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