当前位置: 首页>>代码示例>>Python>>正文


Python Search.get_sobject方法代码示例

本文整理汇总了Python中pyasm.search.Search.get_sobject方法的典型用法代码示例。如果您正苦于以下问题:Python Search.get_sobject方法的具体用法?Python Search.get_sobject怎么用?Python Search.get_sobject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.search.Search的用法示例。


在下文中一共展示了Search.get_sobject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_client_platform

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
def create_client_platform(server, client_code, platform):
    """
    On the insert|twog/title event, search for an existing connection from the title's client to platform.
    If no entry exists in the twog/client_platform table, create it by inserting the client_code, platform_code,
    a name, and a connection_status set to 'disconnected'.

    :param server: The TacticServerStub object
    :param client_code: The client's unique code identifier
    :param platform: The platform object
    :return: None
    """

    # The platform_code we need is not included in the Title sobject. We have to query for it using the platform name.
    platform_code_search = Search("twog/platform")
    platform_code_search.add_filter('name', platform)
    platform_search_object = platform_code_search.get_sobject()
    platform_code = platform_search_object.get_value('code')

    # Using the client_code and platform_code, search for an existing entry.
    client_platform_connection_search = Search("twog/client_platform")
    client_platform_connection_search.add_filter('client_code', client_code)
    client_platform_connection_search.add_filter('platform_code', platform_code)
    client_platform_connection = client_platform_connection_search.get_sobject()

    # If the twog/client_platform is not found, create it. If it already exists, then nothing happens.
    if not client_platform_connection:
        # Using the client_code, get the client name (needed for the 'name' column data).
        client_name_search = Search("twog/client")
        client_name_search.add_filter('code', client_code)
        client_name = client_name_search.get_sobject().get_value('name')

        # Finally, insert the entry into the twog/client_platform table.
        server.insert('twog/client_platform', {'client_code': client_code, 'platform_code': platform_code,
                                               'name': '{0} to {1}'.format(client_name, platform),
                                               'connection_status': 'disconnected'})
开发者ID:2gDigitalPost,项目名称:custom,代码行数:37,代码来源:client_platform_create.py

示例2: _test_cache

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def _test_cache(self):
        from pyasm.common import Config

        Config.set_value("security", "mode", "cache", no_exception=True)
        #Config.set_value("security", "authenticate_class", "pyasm.security.authenticate_test.AutocreateAuthenticate", no_exception=True)
        Config.set_value("security", "authenticate_class", "pyasm.security.mms_authenticate.MMSAuthenticate", no_exception=True)
        mode = Config.get_value("security", "authenticate_class", use_cache=False)

        mode = Config.get_value("security", "mode", use_cache=False)
        self.assertEquals(mode, "cache")


        # verify that the user exists in the database
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertEquals(None, login)


        from pyasm.search import Transaction
        transaction = Transaction.get(create=True)
        transaction.start()

        self.security.login_user("foofoo", "wow")

        # verify that the user exists in the database
        search = Search("sthpw/login")
        search.add_filter("login", "foofoo")
        login = search.get_sobject()
        self.assertNotEquals(None, login)
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:authenticate_test.py

示例3: get_config

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def get_config(my):
        config = None
        config_xml = my.kwargs.get("config_xml")
        if config_xml:
            config = WidgetConfig.get(xml=config_xml, view=my.view)
            return config

        # this is the new preferred way of defining CustomLayoutWdg
        search = Search("config/widget_config")
        if my.category:
            search.add_filter("category", my.category)
        else:
            search.add_filter("category", "CustomLayoutWdg")
        if my.search_type:
            search.add_filter("search_type", my.search_type)

        search.add_filter("view", my.view)

        config = search.get_sobject()
        if config:
            return config
        # if it is not defined in the database, look at a config file

        includes = my.kwargs.get("include")
        if includes:
            includes = includes.split("|")

            for include in includes:
                tmp_path = __file__
                dir_name = os.path.dirname(tmp_path)
                file_path = "%s/../config/%s" % (dir_name, include)
                config = WidgetConfig.get(file_path=file_path, view=my.view)
                if config and config.has_view(my.view):
                    return config

        # deprecated approach, assuming a "CustomLayoutWdg" as search_type,
        # is deprecated
        if not config:
            search = Search("config/widget_config")
            if my.category:
                search.add_filter("category", my.category)
            if my.search_type:
                search.add_filter("search_type", "CustomLayoutWdg")

            search.add_filter("view", my.view)

            config = search.get_sobject()

        # if not config and my.search_type and my.view:
        #    config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
        # this is the new preferred way of defining CustomLayoutWdg
        # NOTE: this finds a definition where search type is not explicitly
        # given>
        if not config:
            search = Search("config/widget_config")
            search.add_filter("view", my.view)
            search.add_filter("search_type", None)
            config = search.get_sobject()

        return config
开发者ID:hellios78,项目名称:TACTIC,代码行数:62,代码来源:custom_layout_wdg.py

示例4: main

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
def main(server=None, trigger_input=None):
    """
    On the insert|twog/title event, search for an existing connection from the title's client to platform.
    If no entry exists in the twog/client_platform table, create it by inserting the client_code, platform_code,
    a name, and a connection_status set to 'disconnected'.

    :param server: the TacticServerStub object
    :param trigger_input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """
    if not trigger_input:
        return

    try:
        from pyasm.search import Search

        # Get the sobject. It should come with a platform name and client_code (unfortunately it doesn't contain the
        # platform_code right now, hopefully that changes sometime soon).
        sob = trigger_input.get('sobject')
        client_code = sob.get('client_code')
        platform = sob.get('platform')

        # As mentioned above, the platform_code we need is not included in the Title sobject. We have to query for it
        # using the platform name.
        platform_code_search = Search("twog/platform")
        platform_code_search.add_filter('name', platform)
        platform_search_object = platform_code_search.get_sobject()
        platform_code = platform_search_object.get_value('code')

        # Using the client_code and platform_code, search for an existing entry.
        client_platform_connection_search = Search("twog/client_platform")
        client_platform_connection_search.add_filter('client_code', client_code)
        client_platform_connection_search.add_filter('platform_code', platform_code)
        client_platform_connection = client_platform_connection_search.get_sobject()

        # If the twog/client_platform is not found, create it. If it already exists, then nothing happens.
        if not client_platform_connection:
            # Using the client_code, get the client name (needed for the 'name' column data).
            client_name_search = Search("twog/client")
            client_name_search.add_filter('code', client_code)
            client_name = client_name_search.get_sobject().get_value('name')

            # Finally, insert the entry into the twog/client_platform table.
            server.insert('twog/client_platform', {'client_code': client_code, 'platform_code': platform_code,
                                                   'name': '{0} to {1}'.format(client_name, platform),
                                                   'connection_status': 'disconnected'})
    except AttributeError as e:
        traceback.print_exc()
        print str(e) + '\nMost likely the server object does not exist.'
        raise e
    except KeyError as e:
        traceback.print_exc()
        print str(e) + '\nMost likely the input dictionary does not exist.'
        raise e
    except Exception as e:
        traceback.print_exc()
        print str(e)
        raise e
开发者ID:2gDigitalPost,项目名称:custom,代码行数:60,代码来源:create_client_platform_connection_on_title_insert.py

示例5: get_platform_connection_by_package_sobject

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
def get_platform_connection_by_package_sobject(package_sobject):
    order_search = Search('twog/order')
    order_search.add_code_filter(package_sobject.get('order_code'))
    order_sobject = order_search.get_sobject()

    platform_connection_search = Search('twog/platform_connection')
    platform_connection_search.add_filter('platform_code', package_sobject.get('platform_code'))
    platform_connection_search.add_filter('division_code', order_sobject.get('division_code'))
    platform_connection = platform_connection_search.get_sobject()

    return platform_connection
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:13,代码来源:utils.py

示例6: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def execute(self):
        dirname = os.path.dirname(self.script_path)
        basename = os.path.basename(self.script_path)

        project = Project.get()

        # treat the code as a python
        search = Search("config/custom_script")
        search.add_filter("folder", dirname)
        search.add_filter("title", basename)
        script_sobj = search.get_sobject()

        if not script_sobj:
            try:
                # get from the sthpw database
                search = Search("sthpw/custom_script")
                search.add_filter("folder", dirname)
                search.add_filter("title", basename)
                script_sobj = search.get_sobject()
                if not script_sobj:
                    print("WARNING: Script with path [%s] does not exist in this project [%s] or Admin Site" % (self.script_path, project.get_code()))
                    return {}
            except:
                print("WARNING: Script with path [%s] does not exist in this project [%s] or Admin Site" % (self.script_path, project.get_code()))
                return

        script = script_sobj.get_value("script")
        if not script:
            print("WARNING: Empty python script [%s]" %script_sobj.get_code())
            return {}



        if self.trigger_sobj:
            trigger_sobj = self.trigger_sobj.get_sobject_dict()
            self.input['trigger_sobject'] = trigger_sobj

        language = script_sobj.get_value("language")
        if language == "server_js":
            from tactic.command import JsCmd
            cmd = JsCmd(code=script, input=self.input)
        else:
            cmd = PythonCmd(code=script, input=self.input)

        ret_val = cmd.execute()

        self.ret_val = ret_val
        self.info['result'] = ret_val

        #print "input: ", self.input
        #print "output: ", self.output
        #print "options: ", self.options

        return ret_val
开发者ID:mincau,项目名称:TACTIC,代码行数:56,代码来源:python_cmd.py

示例7: do_search

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def do_search(my):
        '''this widget has its own search mechanism'''

        web = WebContainer.get_web()
        
        # get the sobject that is to be edited
        id = my.search_id

        # if no id is given, then create a new one for insert
        search = None
        sobject = None
        search_type_base = SearchType.get(my.search_type).get_base_key()
        if my.mode == "insert":
            sobject = SearchType.create(my.search_type)
            my.current_id = -1
            # prefilling default values if available
            value_keys = web.get_form_keys()
            if value_keys:
                
                for key in value_keys:
                    value = web.get_form_value(key)
                    sobject.set_value(key, value)
        else:
            search = Search(my.search_type)

            # figure out which id to search for
            if web.get_form_value("do_edit") == "Edit/Next":
                search_ids = web.get_form_value("%s_search_ids" %search_type_base)
                if search_ids == "":
                    my.current_id = id
                else:
                    search_ids = search_ids.split("|")
                    next = search_ids.index(str(id)) + 1
                    if next == len(search_ids):
                        next = 0
                    my.current_id = search_ids[next]

                    last_search = Search(my.search_type)
                    last_search.add_id_filter( id )
                    my.last_sobject = last_search.get_sobject()

            else:
                my.current_id = id

            search.add_id_filter( my.current_id )
            sobject = search.get_sobject()

        if not sobject and my.current_id != -1:
            raise EditException("No SObject found")

        # set all of the widgets to contain this sobject
        my.set_sobjects( [sobject], search )
开发者ID:funic,项目名称:TACTIC,代码行数:54,代码来源:edit_wdg.py

示例8: main

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
def main(server=None, trigger_input=None):
    """
    On the insert|twog/package event, search for an existing connection from the package's division to platform.
    If no entry exists in the twog/platform_connection table, create it by inserting the division_code, platform_code,
    and a connection_status set to 'disconnected'.

    :param server: the TacticServerStub object
    :param trigger_input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """
    if not trigger_input:
        return

    try:
        from pyasm.search import Search

        # Get the package sobject.
        package_sobject = trigger_input.get('sobject')

        # Search for the twog/order sobject (which leads to the division)
        order_search = Search('twog/order')
        order_search.add_code_filter(package_sobject.get('order_code'))
        order_sobject = order_search.get_sobject()

        # Search for the twog/division sobject
        division_search = Search('twog/division')
        division_search.add_code_filter(order_sobject.get('division_code'))
        division_sobject = division_search.get_sobject()

        # Search for an existing entry in the twog/platform_connection table. If it already exists, no action is needed
        existing_platform_connection_search = Search('twog/platform_connection')
        existing_platform_connection_search.add_filter('division_code', division_sobject.get_code())
        existing_platform_connection_search.add_filter('platform_code', package_sobject.get('platform_code'))
        existing_platform_connection = existing_platform_connection_search.get_sobject()

        if not existing_platform_connection:
            # Insert the new entry
            data_to_insert = {
                'division_code': division_sobject.get_code(),
                'platform_code': package_sobject.get('platform_code'),
                'connection_status': 'disconnected'
            }

            server.insert('twog/platform_connection', data_to_insert)

    except Exception as e:
        traceback.print_exc()
        print str(e)
        raise e
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:51,代码来源:insert_platform_connection_on_package_insert.py

示例9: get_task_estimated_hours_from_package_task_code

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
def get_task_estimated_hours_from_package_task_code(task_code):
    """
    From a sthpw/task sobject, assumed to be attached to a twog/package, get the estimated hours for the task.
    This is taken from the twog/platform_connection sobject related to the package.

    :param task_code: sthpw/task code (must be for a twog/package)
    :return: Float
    """

    # Get the task sobject
    task = get_sobject_by_code('sthpw/task', task_code)

    # Get the package sobject
    package = task.get_parent()

    # Get the platform code, used for the platform_connection search
    platform_code = package.get('platform_code')

    # Get the division code, also for the platform_connection search
    division = get_client_division_sobject_from_order_code(package.get('order_code'))
    division_code = division.get_code()

    # Search for the platform_connection
    platform_connection_search = Search('twog/platform_connection')
    platform_connection_search.add_filter('platform_code', platform_code)
    platform_connection_search.add_filter('division_code', division_code)
    platform_connection = platform_connection_search.get_sobject()

    # Get the estimated hours, and convert to a float
    estimated_hours = float(platform_connection.get('estimated_hours'))

    return estimated_hours
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:34,代码来源:utils.py

示例10: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def get_display(self):
        outer_div = DivWdg()
        outer_div.set_id('add_deliverable_files_to_package')

        order_code = self.package_sobject.get('order_code')
        order_search = Search('twog/order')
        order_search.add_code_filter(order_code)
        order_sobject = order_search.get_sobject()

        deliverable_files = get_deliverable_files_in_order(order_sobject)
        selected_files = get_files_for_package(self.package_sobject.get_code())

        # Only show the selectable files and the submit button if the parent order has any deliverable files
        if deliverable_files:
            deliverable_file_select_wdg = get_files_checkbox_from_file_list(deliverable_files, selected_files)
            outer_div.add(deliverable_file_select_wdg)

            submit_button = SubmitWdg('Submit')
            submit_button.add_behavior(self.get_submit_button_behavior())

            outer_div.add(submit_button)
        else:
            outer_div.add('<div>No deliverable files are available for this Order yet.</div>')

        return outer_div
开发者ID:2gDigitalPost,项目名称:custom-rewrite,代码行数:27,代码来源:add_deliverable_files_to_package_wdg.py

示例11: postprocess

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def postprocess(self):
        web = WebContainer.get_web()
        value = web.get_form_value( self.get_input_name() )
        if not value:
            return
        
        # get all fo the sobjects from the search keys
        instance_type = self.get_option("instance_type")
        
        # path is used for self-relating in an instance table
        src_path = self.get_option("path")

    
        #src_sobject = self.sobject

        search = Search(self.sobject.get_search_type())
        search.add_id_filter(self.sobject.get_id())
        src_sobject = search.get_sobject()

        # this is passed in from EditCmd in insert mode
        parent_key = self.get_option('parent_key')
        # in some rare cases we have project as the parent_key
        if parent_key and self.is_insert and 'sthpw/project' not in parent_key:
            # this is the parent
            dst_sobject = SearchKey.get_by_search_key(parent_key)

            # add all the new sobjects
            #instances = dst_sobject.get_related_sobject(instance_type)
            instance = SearchType.create(instance_type)
            instance.add_related_connection(src_sobject, dst_sobject, src_path=src_path)

            instance.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:34,代码来源:drop_element_wdg.py

示例12: handle_config2

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def handle_config2(my):
        """for db column search config stuff, not used yet"""
        web = WebContainer.get_web()

        search_type = "SearchTypeSchema"
        view = "definition"

        config_search_type = "config/widget_config"

        search = Search(config_search_type)
        search.add_filter("search_type", search_type)
        search.add_filter("view", view)
        config = search.get_sobject()
        if not config:
            config = SearchType.create(config_search_type)
            config.set_value("search_type", search_type)
            config.set_value("view", view)
            xml = config.get_xml_value("config", "config")
            root = xml.get_root_node()
            # reinitialize
            config._init()

            # build a new config
            view_node = xml.create_element(view)
            root.appendChild(view_node)

        config_mode = web.get_form_value("config_mode")
        if config_mode == "advanced":
            config_string = web.get_form_value("config_xml")
        else:
            config_data_type = web.get_form_value("config_data_type")
            if config_data_type == "Other...":
                config_data_type = web.get_form_value("config_data_type_custom")
            config_nullable = web.get_form_value("config_nullable")

            # TAKEN FROM API: should be centralized or something
            from tactic.ui.panel import SideBarBookmarkMenuWdg

            config_view = SideBarBookmarkMenuWdg.get_config(search_type, view)
            node = config_view.get_element_node(my.element_name)
            if node:
                config_xml = config_view.get_xml()

                node = config_view.get_element_node(my.element_name)
                Xml.set_attribute(node, "data_type", config_data_type)
                Xml.set_attribute(node, "nullable", config_nullable)
                Xml.set_attribute(node, "new", "True")

                config_string = config_xml.to_string(node)
            else:
                config_string = """
                <element name="%s" data_type="%s" nullable="%s" new="True"/>
                """ % (
                    my.element_name,
                    config_data_type,
                    config_nullable,
                )

        config.append_xml_element(my.element_name, config_string)
        config.commit_config()
开发者ID:pombredanne,项目名称:TACTIC,代码行数:62,代码来源:search_type_manager_wdg.py

示例13: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def execute(my):
        my.init()

        # create the filters
        my.filters = []
        """
        for element_name in my.config.get_element_names():
            
            filter = my.config.get_display_widget(element_name)
            my.filters.append(filter)

        # make sure there is at least one filter defined
        assert my.filters

        """
        config = "<config>\n"
        config += "<filter>\n"

        # get all of the serialized versions of the filters
        """
        for filter in my.filters:
            config += filter.serialize() + "\n"
        """
        filter_data = FilterData.get()
        json = filter_data.serialize()
        value_type = "json"
        config += "<values type='%s'>%s</values>\n" % (value_type, json)
        config += "</filter>\n"
        config += "</config>\n"

        # format the xml
        xml = Xml()
        xml.read_string(config)

        if not my.view:
            saved_view = "saved_search:%s" % my.search_type
        else:
            saved_view = my.view
        #    if my.view.startswith("saved_search:"):
        #        saved_view = my.view
        #    else:
        #        saved_view = "saved_search:%s" % my.view

        # use widget config instead
        search = Search("config/widget_config")
        search.add_filter("view", saved_view)
        search.add_filter("search_type", my.search_type)
        if my.personal:
            search.add_user_filter()
        config = search.get_sobject()

        if not config:
            config = SearchType.create("config/widget_config")
            config.set_value("view", saved_view)
            config.set_value("search_type", my.search_type)
            if my.personal:
                config.set_user()

        config.set_value("config", xml.to_string())
        config.commit()
开发者ID:raidios,项目名称:TACTIC,代码行数:62,代码来源:search_wdg.py

示例14: postprocess

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def postprocess(self):

        search_type = self.get_option("search_type")
        column = self.get_option("column")

        search_type = "construction/login_in_trade"
        column = "trade_code"

        value = self.get_value(self.name)

        
        sobject = self.sobject

        search = Search(search_type)
        search.add_relationship_filter(sobject)
        related = search.get_sobject()

        if not related:
            related = SearchType.create(search_type)
            related.set_parent(sobject)
            
        if not value:
            related.delete()
        else:
            related.set_value(column, value)
            related.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:28,代码来源:edit_wdg_action.py

示例15: execute

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import get_sobject [as 别名]
    def execute(self):

        web = WebContainer.get_web()
        if web.get_form_value("update") != "true":
            return

        self.element_name = self.kwargs.get("element_name")

        security_groups = web.get_form_values("security")
        from pyasm.security import AccessRuleBuilder, AccessManager

        rule_group = "side_bar"

        for security_group in security_groups:
            if not security_group:
                continue

            search = Search("sthpw/login_group")
            search.add_filter("login_group", security_group)
            login_group = search.get_sobject()
            assert login_group

            access_rules = login_group.get_xml_value("access_rules")

            # add the rule to each group
            builder = AccessRuleBuilder(access_rules)
            builder.add_rule(rule_group, self.element_name, "deny")

            login_group.set_value("access_rules", builder.to_string())
            login_group.commit()
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:search_type_manager_wdg.py


注:本文中的pyasm.search.Search.get_sobject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。