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


Python Search.add_op方法代码示例

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


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

示例1: delete_sobject

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def delete_sobject(my, sobject):

        search_type = sobject.get_base_search_type()

        # this is used by API method delete_sobject
        auto_discover = my.kwargs.get("auto_discover")
        
        values = my.kwargs.get("values")
        if values:
            related_types = values.get("related_types")
        elif auto_discover:
            related_types = SearchType.get_related_types(search_type, direction="children")
        else:
            related_types = None

        # always delete notes and task and snapshot
        #if not related_types:
        #    related_types = ['sthpw/note', 'sthpw/task', 'sthpw/snapshot']
        #related_types = my.schema.get_related_search_types(search_type)
        if related_types:
            for related_type in related_types:
                if not related_type or related_type == search_type:
                    continue

                # snapshots take care of sthpw/file in the proper manner, so
                # skip them here
                if related_type == 'sthpw/file':
                    continue

                related_sobjects = sobject.get_related_sobjects(related_type)
                for related_sobject in related_sobjects:
                    if related_type == 'sthpw/snapshot':
                        my.delete_snapshot(related_sobject)
                    else:
                        related_sobject.delete()


        # implicitly remove "directory" files associated with the sobject
        search = Search("sthpw/file")
        search.add_op("begin")
        search.add_filter("file_name", "")
        search.add_null_filter("file_name")
        search.add_op("or")
        search.add_parent_filter(sobject)
        file_objects = search.get_sobjects()
        for file_object in file_objects:
            base_dir = Environment.get_asset_dir()
            relative_dir = file_object.get("relative_dir")
            lib_dir = "%s/%s" % (base_dir, relative_dir)
            print "removing: ", lib_dir
            FileUndo.rmdir(lib_dir)
            file_object.delete()


        # finally delete the sobject
        print "deleting: ", sobject.get_search_key()
        if search_type == 'sthpw/snapshot':
            my.delete_snapshot(sobject)
        else:
            sobject.delete()
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:62,代码来源:delete_wdg.py

示例2: do_delete

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def do_delete(self, sobject, related_types=None):

        search_type = sobject.get_base_search_type()

        # always delete notes and task and snapshot
        if not related_types:
            related_types = ['sthpw/note', 'sthpw/task', 'sthpw/snapshot']
        #related_types = self.schema.get_related_search_types(search_type)

        if related_types:
            for related_type in related_types:
                if not related_type or related_type == search_type:
                    continue

                # snapshots take care of sthpw/file in the proper manner, so
                # skip them here
                if related_type == 'sthpw/file':
                    continue

                related_sobjects = sobject.get_related_sobjects(related_type)
                for related_sobject in related_sobjects:
                    if related_type == 'sthpw/snapshot':
                        self.delete_snapshot(related_sobject)
                    else:
                        related_sobject.delete()
                        #self.do_delete(related_sobject)


        # implicitly remove "directory" files associated with the sobject
        search = Search("sthpw/file")
        search.add_op("begin")
        search.add_filter("file_name", "")
        search.add_null_filter("file_name")
        search.add_op("or")
        search.add_parent_filter(sobject)
        file_objects = search.get_sobjects()

        #if file_objects:
        #    print("Removing [%s] file objects" % len(file_objects))

        for file_object in file_objects:
            base_dir = Environment.get_asset_dir()
            relative_dir = file_object.get("relative_dir")
            lib_dir = "%s/%s" % (base_dir, relative_dir)
            FileUndo.rmdir(lib_dir)
            file_object.delete()


        # finally delete the sobject
        print("Deleting: ", sobject.get_search_key())
        if search_type == 'sthpw/snapshot':
            self.delete_snapshot(sobject)
        else:
            sobject.delete()
开发者ID:mincau,项目名称:TACTIC,代码行数:56,代码来源:delete_wdg.py

示例3: get_search_types

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def get_search_types(my, include_sthpw=False, include_config=False, include_multi_project=False):
        '''get all the search types in this project'''
        if my.search_types != None:
            return my.search_types

        project_type = my.get_value("type")

        search = Search("sthpw/search_object")

        project_code = my.get_code()
        namespaces = [project_code]
        namespaces.append(project_type)

        if include_sthpw:
            namespaces.append("sthpw")
        if include_config:
            namespaces.append("config")
        if include_multi_project:
            if not include_config:
                search.add_filter('namespace','config',op='!=')
            if not include_sthpw:
                search.add_filter('namespace','sthpw',op='!=')
            search.add_op('begin')
            search.add_filter('database','{project}')
            

        search.add_filters("namespace", namespaces)

        if include_multi_project:
            search.add_op('or')

        search.add_order_by("search_type")
        search_type_objs = search.get_sobjects()

        """
        from pyasm.biz import Schema
        schema = Schema.get()
        xml = schema.get_xml_value("schema")
        search_types = xml.get_values("schema/search_type/@name")
        search = Search("sthpw/search_object")
        search.add_filters("code", search_types)
        search_type_objs = search.get_sobjects()
        """



        search_types = []
        for x in search_type_objs:
            # to avoid the old ill-defined prod/custom_property defined in sthpw namespace
            if (x.get_value('namespace') == 'sthpw' and x.get_value('search_type').find('custom_property') == -1)\
                or my.has_table(x):
                search_types.append(x)
        return search_types
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:55,代码来源:project.py

示例4: get_subscriptions

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def get_subscriptions(my, category, mode="new"):

        search = Search("sthpw/subscription")
        search.add_user_filter()
        if category:
            search.add_filter("category", category)



        if mode == "new":
            search.add_op("begin")
            search.add_filter("last_cleared", '"message"."timestamp"', quoted=False, op="<")
            search.add_filter("last_cleared", "NULL", quoted=False, op="is")
            search.add_op("or")


            #project_code = Project.get_project_code()
            #search.add_filter("project_code", project_code )

            # use an inner join because if there are no messages, we don't
            # want the subscription
            search.add_order_by("message.timestamp", direction="desc", join="INNER")

            # don't show user message except when category is certain values
            user = Environment.get_user_name()
            search.add_op("begin")
            search.add_filter("login", user, op="!=", table="message")
            search.add_filters("category", ["script","default","sobject"], table="message")
            search.add_op("or")
        else:
            search.add_order_by("message.timestamp", direction="desc")

        subscriptions = search.get_sobjects()

        return subscriptions
开发者ID:hellios78,项目名称:TACTIC,代码行数:37,代码来源:message_wdg.py

示例5: on_insert

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def on_insert(my):
        '''Function that should be run on insert/update. It's already automatically called during insert.
        On update, the caller needs to call this explicitly. It checks the search type
        this pipeline is associated with and if there is no pipeline code
        column, then update it.  It updates the process table also.'''
        search_type = my.get_value('search_type')
        my.update_process_table(search_type=search_type)

        # don't do anything for task sType
        if search_type =='sthpw/task':
            return


        if not search_type:
            return

        if ProdSetting.get_value_by_key('autofill_pipeline_code') != 'false':
            try:
                columns = SearchType.get_columns(search_type)
                if not 'pipeline_code' in columns:
                    # add the pipeline code column
                    from pyasm.command import ColumnAddCmd
                    cmd = ColumnAddCmd(search_type, "pipeline_code", "varchar")
                    cmd.execute()
            except SqlException, e:
                print "Error creating column [pipeline_code] for %" %search_type 
                pass

            # go through all of the sobjects and set all the empty ones
            # to the new pipeline
            search = Search(search_type)
            search.add_op("begin")
            search.add_filter("pipeline_code", "NULL", op='is', quoted=False)
            search.add_filter("pipeline_code", "")
            search.add_op("or")
            sobject_ids = search.get_sobject_ids()
            
            if sobject_ids:
                # this is much faster and memory efficient
                db_resource = SearchType.get_db_resource_by_search_type(search_type)
                sql = DbContainer.get(db_resource)
                tbl = search.get_table()
                sobject_ids = [str(x) for x in sobject_ids]
                pipeline_code =  my.get_value("code")
                sql.do_update('''UPDATE "%s" SET "pipeline_code" = '%s' WHERE id in (%s) ''' %(tbl, pipeline_code, ','.join(sobject_ids)))
            """
开发者ID:0-T-0,项目名称:TACTIC,代码行数:48,代码来源:pipeline.py

示例6: get_connections

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def get_connections(cls, sobjects, direction="dst", context='', context_filters=[], src_search=None):
        '''return a Search instance if src_search is provided'''
        if not sobjects and not src_search:
            return []
        search = Search(SObjectConnection)

        if direction == "dst":
            prefix = "src"
        else:
            prefix = "dst"
        
        if src_search:
            search.add_filter("%s_search_type" % prefix, src_search.get_search_type() )
            search.add_search_filter('%s_search_id'%prefix, src_search, op="in") 
        else:
            search_types = [x.get_search_type() for x in sobjects]
            search_ids = [x.get_id() for x in sobjects]

            if len(Common.get_unique_list(search_types)) == 1:
                search.add_filter("%s_search_type" % prefix, search_types[0] )
                search.add_filters("%s_search_id" % prefix, search_ids)
            else:
                search.add_op("begin")
                for search_type, search_id in zip(search_types, search_ids):
                    search.add_op("begin")
                    search.add_filter("%s_search_type" % prefix, search_type )
                    search.add_filter("%s_search_id" % prefix, search_id )
                    search.add_op("and")
                search.add_op("or")

        if context:
            search.add_filter("context", context)
        elif context_filters:
            search.add_op_filters(context_filters)

        if src_search:
            return search

		# cache for connection sobjects
        key = search.get_statement()
        cache = Container.get("SObjectConnection:cache")
        if cache == None:
            cache = {}
            Container.put("SObjectConnection:cache", cache)

        ret_val = cache.get(key)
        if ret_val != None:
            return ret_val

        
        connections = search.get_sobjects()
        
        return connections
开发者ID:0-T-0,项目名称:TACTIC,代码行数:55,代码来源:sobject_connection.py

示例7: get_connections

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def get_connections(cls, sobjects, direction="dst", context='', context_filters=[]):

        if not sobjects:
            return []
        search_types = [x.get_search_type() for x in sobjects]
        search_ids = [x.get_id() for x in sobjects]
    
        if direction == "dst":
            prefix = "src"
        else:
            prefix = "dst"

        search = Search(SObjectConnection)

        search.add_op("begin")
        for search_type, search_id in zip(search_types, search_ids):
            search.add_op("begin")
            search.add_filter("%s_search_type" % prefix, search_type )
            search.add_filter("%s_search_id" % prefix, search_id )
            search.add_op("and")
        search.add_op("or")

        if context:
            search.add_filter("context", context)
        elif context_filters:
            search.add_op_filters(context_filters)


        key = search.get_statement()
        cache = Container.get("SObjectConnection:cache")
        if cache == None:
            cache = {}
            Container.put("SObjectConnection:cache", cache)

        ret_val = cache.get(key)
        if ret_val != None:
            return ret_val


        connections = search.get_sobjects()
        
        return connections
开发者ID:blezek,项目名称:TACTIC,代码行数:44,代码来源:sobject_connection.py

示例8: get_sobject_files

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def get_sobject_files(my, sobject):
        paths = []

        show_versionless = my.kwargs.get("show_versionless")
        if show_versionless in [True, 'true']:
            show_versionless = True
        else:
            show_versionless = False


        if isinstance(sobject, Snapshot):
            snapshots = [sobject]
        else:
            # get the snapshots
            versions = my.get_value("versions")
            search = Search("sthpw/snapshot")

            search.add_parent_filter(sobject)


            if not versions or versions == 'latest':
                search.add_filter("is_latest", True)
            elif versions == 'current':
                search.add_filter("is_current", True)

            if show_versionless:
                search.add_filter("version", -1)
                search.add_op('or')

            processes = my.kwargs.get("processes")
            process = my.get_value("process")
            if process and process != 'all':
                search.add_filter("process", process)
            if processes:
                search.add_filters("process", processes)

            snapshots = search.get_sobjects()

            #snapshots = Snapshot.get_by_sobject(sobject)

        for snapshot in snapshots:

            exclude = ['web','icon']
            snapshot_paths = snapshot.get_all_lib_paths(exclude_file_types=exclude)
            files = snapshot.get_all_file_objects(exclude_file_types=exclude)
            for path, file in zip(snapshot_paths, files):

                # if the path is a directory, get all of the files
                if os.path.isdir(path):
                    for root, dirnames, filenames in os.walk(path):

                        for filename in filenames:
                            item_path = "%s/%s" % (root, filename)
                            paths.append(item_path)
                            my.files[item_path] = file

                        for dirname in dirnames:
                            item_path = "%s/%s/" % (root, dirname)
                            paths.append(item_path)
                            my.files[item_path] = file

                else:
                    paths.append(path)
                    my.snapshots[path] = snapshot
                    my.files[path] = file

        return paths
开发者ID:asmboom,项目名称:TACTIC,代码行数:69,代码来源:snapshot_files_wdg.py

示例9: get

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def get(cls, reset_cache=False, project_code=None):
        
        if not project_code:
            from project import Project
            project_code = Project.get_project_code()

        if not reset_cache:
            schema = Container.get("Schema:%s"%project_code)
            
            if schema:
                return schema

       

        # the predefined ones cannot be overriden
        if project_code in ['unittest']:
            schema = cls.get_predefined_schema(project_code)
            schema.init()
            sthpw_schema = cls.get_predefined_schema("admin")
            sthpw_schema.init()
            schema.sthpw_schema = sthpw_schema
            #return schema

        elif project_code in ['sthpw','admin']:
            sthpw_schema = cls.get_predefined_schema("admin")
            sthpw_schema.init()
            return sthpw_schema



        # by default the code of the schema is the project code
        #schema = cls.get_by_project_code(project_code)
        # find using explicit search ... too much nested caching going
        # on here.  It is confusing when changing schema
        search = Search("sthpw/schema")
        search.add_op("begin")
        if project_code not in ['unittest']:
            search.add_filter("code", project_code)
        search.add_filter("project_code", project_code)
        search.add_op("or")
        schemas = search.get_sobjects()

        if project_code in ['unittest']:
            schemas.insert(0, schema)

        if len(schemas) > 1:
            schema = SearchType.create("sthpw/schema")
            schema.set_value("code", project_code)
            schema.set_value("project_code", project_code)

            new_xml = []
            new_xml.append("<schema>\n")

            for schema in schemas:
                xml = schema.get_xml_value("schema")
                nodes = xml.get_nodes("schema/*")
                for node in nodes:
                    new_xml.append(xml.to_string(node))

            new_xml.append("</schema>\n")

            new_xml = "".join(new_xml)
            #print new_xml
            schema.set_value("schema", new_xml)

        elif schemas:
            schema = schemas[0]

        else:
            schema = None


        # if the project schema does not exist, then create an empty one
        if not schema:
            schema = Schema("sthpw/schema", dependencies=False)
            schema.set_value("schema", "<schema/>")
            schema.set_value("code", project_code)
            schema.init()
            schema.add_dependencies()



        Container.put("Schema:%s"%project_code, schema)
     
        return schema
开发者ID:mincau,项目名称:TACTIC,代码行数:87,代码来源:schema.py

示例10: handle_search

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

        # this is an absolute expression
        my.search_expr = my.kwargs.get("search_expr")
        my.search_type = my.kwargs.get("search_type")
        if not my.search_type:
            my.search_type = 'sthpw/task'
        if my.search_expr:
            search = Search.eval(my.search_expr)

        else:
            

            my.op_filters = my.kwargs.get("filters")
            if my.op_filters:
                if isinstance(my.op_filters, basestring):
                    my.op_filters = eval(my.op_filters)
            search = Search(my.search_type)
            if my.op_filters:
                search.add_op_filters(my.op_filters)

        my.start_column = my.kwargs.get('start_date_col')
        if not my.start_column:
            my.start_column = 'bid_start_date'

        my.end_column = my.kwargs.get('end_date_col')
        if not my.end_column:
            my.end_column = 'bid_end_date'

       
        

        search.add_op('begin')

        if my.handler:
            my.handler.alter_search(search)

        search.add_op('or')




        my.start_date = datetime(my.year, my.month, 1)
        next_month = my.month+1
        next_year = my.year
        if next_month > 12:
            next_month = 1
            next_year += 1

        my.end_date = datetime(next_year, next_month, 1)
        my.end_date = my.end_date - timedelta(days=1)

        # outer begin
        search.add_op('begin')

        search.add_op('begin')
        search.add_date_range_filter(my.start_column, my.start_date, my.end_date)
        search.add_date_range_filter(my.end_column, my.start_date, my.end_date)

        search.add_op('or')
        search.add_op('begin')
        search.add_filter(my.start_column, my.start_date, op='<=')
        search.add_filter(my.end_column, my.end_date, op='>=')
        search.add_op('and')
        
        search.add_op('or')


        search.add_order_by(my.start_column)
        print "search: ", search.get_statement()

        my.sobjects = search.get_sobjects()
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:74,代码来源:sobject_calendar_wdg.py

示例11: get_display

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]

#.........这里部分代码省略.........
        inner.add(button_div)
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            collapse = buttons.getElement(".spt_collapse");
            new Fx.Tween(element).start('margin-top', "0px");
            collapse.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )
        """



        reports = []

        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path="%s/../config/reports-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")

        category = my.kwargs.get('category')

        # get all of the configs from the database
        if not category or category in ["custom_reports", "custom_charts"]:
            search = Search("config/widget_config")
            search.add_op("begin")
            if category == "custom_reports":
                search.add_filter("widget_type", "report")
            elif category == "custom_charts":
                search.add_filter("widget_type", "chart")
            elif not category:
                search.add_filters("widget_type", ["chart","report"])

            search.add_op("or")
            db_configs = search.get_sobjects()
        else:
            db_configs = []


        element_names = my.kwargs.get("element_names")
        if element_names is None:
            element_names = config.get_element_names()



        project = Project.get()

        for element_name in element_names:
            key = {'project': project.get_code(), 'element': element_name}
            key2 = {'project': project.get_code(), 'element': '*'}
            key3 = {'element': element_name}
            key4 = {'element': '*'}
            keys = [key, key2, key3, key4]
            if not top.check_access("link", keys, "view", default="deny"):
                continue

            attrs = config.get_element_attributes(element_name)
            report_data = {}
开发者ID:0-T-0,项目名称:TACTIC,代码行数:70,代码来源:reports_wdg.py

示例12: get_by_sobjects

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op [as 别名]
    def get_by_sobjects(sobjects, process=None, order=True):

        if not sobjects:
            return []


        # quickly go through the sobjects to determine if their search types
        # are the same
        multi_stypes = False
        for sobject in sobjects:
            if sobject.get_search_type() != sobjects[0].get_search_type():
                multi_stypes = True
                break

        
        search = Search( Task.SEARCH_TYPE )
        if multi_stypes:
            # sort this into a dictionary and make multiple calls to 
            # search.add_relationship_filters
            # use the first sobject as a sample
            sobjects_dict = {}
            for sobject in sobjects:
                st = sobject.get_search_type()
                sobj_list = sobjects_dict.get(st)
                if sobj_list == None:
                    sobjects_dict[st] = [sobject]
                else:
                    sobj_list.append(sobject)

        
            search.add_op('begin')
            for key, sobj_list in sobjects_dict.items():
                search.add_op('begin')
                search.add_relationship_filters(sobj_list)
                search.add_op('and')
            search.add_op('or')



        else:

            from pyasm.biz import Schema
            schema = Schema.get()

            # FIXME: why doesn't the ops work here?
            filters = []
            search.add_relationship_filters(sobjects)
            """
            for sobject in sobjects:
                search_type = sobject.get_search_type()
                attrs = schema.get_relationship_attrs("sthpw/task", search_type)
                attrs = schema.resolve_relationship_attrs(attrs, "sthpw/task", search_type)
                search_code = sobject.get_value(attrs.get("to_col"))
                #search_code = sobject.get_value("code")
                #search.add_filter('search_type', search_type)
                #search.add_filter('search_id', search_id, quoted=False)
                #search.add_op("and")
                if attrs.get("from_col") == "search_code":
                    filters.append("search_type = '%s' and search_code = '%s'" % (search_type, search_code))
                else:
                    filters.append("search_type = '%s' and search_id = %s" % (search_type, search_code))
            search.add_where(" or ".join(filters))
            """

        search.add_order_by("search_type")

        search.add_order_by("search_code")
        search.add_order_by("search_id")



        # get the pipeline of the sobject
        pipeline = Pipeline.get_by_sobject(sobject)
        if order:
            if pipeline:
                process_names = pipeline.get_process_names(True)
                search.add_enum_order_by("process", process_names)
            else:
                search.add_order_by("process")

            search.add_order_by("id")

        if process:
           
            if isinstance(process, basestring):
                search.add_filter("process", process)
            else:
                search.add_filters("process", process)

        tasks = search.get_sobjects()
        return tasks
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:93,代码来源:task.py

示例13: get_display

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

        menus = []

        widget = DivWdg(id='ProjectSelectWdg', css='spt_panel')
        widget.set_attr('spt_class_name', 'tactic.ui.app.ProjectSelectWdg') 
        if not WebContainer.get_web().is_IE():
            widget.add_style("float: right")

        from tactic.ui.widget import SingleButtonWdg
        button = SingleButtonWdg(title='Open Project', icon=IconWdg.PROJECT, show_arrow=True)
        widget.add(button)


        #from tactic.ui.activator import ButtonForDropdownMenuWdg
        #menu_data = []
        #menu_id = "project_select_menu"

        allowed = Project.get_user_projects()
        allowed_codes = [x.get_code() for x in allowed]

        search = Search("sthpw/project")
        search.add_filters("code", allowed_codes)
        # ignore some builtin projects
        search.add_where("\"code\" not in ('admin','sthpw','unittest')")
        search.add_op("begin")
        #search.add_filter("is_template", 'true', quoted=False, op='!=')
        search.add_filter("is_template", True, op='!=')
        search.add_filter("is_template", 'NULL', quoted=False, op='is')
        search.add_op("or")
        projects = search.get_sobjects()


        from tactic.ui.container import  Menu, MenuItem
        menu = Menu(width=240)
        menus.append(menu)
        menu.set_allow_icons(False)

        security = Environment.get_security()
        if security.check_access("builtin", "view_site_admin", "allow", default="deny") or security.check_access("builtin", "create_projects", "allow", default="deny"):
            menu_item = MenuItem(type='title', label='Project Action')
            menu.add(menu_item)

            menu_item = MenuItem(type='action', label='Create New Project')
            menu.add(menu_item)
            menu_item.add_behavior( {
            'cbjs_action': '''
            //spt.popup.open('create_project_wizard');
            //Effects.fade_in($('create_project_wizard'), 200);
            var env = spt.Environment.get();
            var project = env.get_project();
            if (project == 'admin') {
                spt.tab.set_main_body_top();
                var class_name = 'tactic.ui.app.ProjectCreateWdg';
                spt.tab.add_new("create_project", "Create Project", class_name);
            }
            else {
                document.location = "/tactic/admin/link/create_project";
            }
            '''
            } )


            search = Search("config/url")
            search.add_filter("url", "/index")
            url = search.get_sobject()
            if url:
                menu_item = MenuItem(type='action', label='Open Index')
                menu.add(menu_item)
                menu_item.add_behavior( {
                'cbjs_action': '''
                var env = spt.Environment.get();
                var project = env.get_project();
                //document.location = "/tactic/" + project + "/";
                window.open('/tactic/'+project+'/');
                '''
                } )




        menu_item = MenuItem(type='title', label='Open Project')
        menu.add(menu_item)


        def add_project_menu(menu, project):
            project_code = project.get_code()
            menu_item = MenuItem(type='action', label=project.get_value("title"))

            web = WebContainer.get_web()
            browser = web.get_browser()

            if browser != 'Qt':

                menu_item.add_behavior( {
                'type': 'click_up',
                'project_code': project_code,
                'cbjs_action': '''
                window.open('/tactic/%s/');
                ''' % project_code
#.........这里部分代码省略.........
开发者ID:hellios78,项目名称:TACTIC,代码行数:103,代码来源:page_header_wdg.py

示例14: get_display

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

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

        div = self.top

        div.add("List of Saved Searches: ")
        div.add(HtmlElement.br(2))
        div.add_style("margin: 20px")
        div.add_style("width: 400px")
        div.add_class("spt_saved_search_top")
        
        try:
            search = Search("config/widget_config")
            search.add_op("begin")
            search.add_filter("view", 'saved_search:%', op="like")
            search.add_filter("category", 'search_filter')
            search.add_op("or")
            search.add_op("begin")
            search.add_user_filter()
            search.add_filter("login", "NULL", op="is", quoted=False)
            search.add_op("or")
            search.add_filter("search_type", search_type)
            configs = search.get_sobjects()
        except SearchException as e:
            print("WARNING: ", e)
            configs = []
        except:
            SearchWdg.clear_search_data(search_type)
            raise

        """
        from tactic.ui.panel import TableLayoutWdg
        element_names = ['view','name','description','delete']
        table = TableLayoutWdg(
                search_type=search_type,
                element_names=element_names,
                search=search,
                show_shelf=False,
                show_border=False,
                show_search_limit=False,
                height="auto",

        )
        div.add(table)
        """

        values = [x.get("view") for x in configs]
        labels = [x.get("title") or x.get("view") for x in configs]

        select = SelectWdg("saved_search")
        div.add(select)
        select.set_id("saved_search")
        select.add_class("spt_saved_search_input")
        select.add_empty_option("-- Select --")
        select.set_option("values", values)
        select.set_option("labels", labels)

        retrieve_button = ActionButtonWdg(title="Load")
        behavior = {
            'type':         'click',
            #'cbjs_action':  'spt.dg_table.retrieve_search_cbk(evt, bvr);'
            'cbjs_action':  '''
            var top = bvr.src_el.getParent(".spt_saved_search_top")
            var input = top.getElement(".spt_saved_search_input");
            var value = input.value;
            if (!value) {
                spt.alert("Please select a saved search to load.");
                return;
            }

            var popup = bvr.src_el.getParent(".spt_popup");
            var activator = popup.activator;
            var layout = activator.getElement(".spt_layout");
            spt.table.set_layout(layout);

            spt.table.load_search(value);
            '''
        }
        retrieve_button.add_behavior( behavior )
        retrieve_button.add_style("display: inline-block")


        remove_button = ActionButtonWdg(title="Remove")
        remove_button.add_behavior( {
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_saved_search_top")
            var input = top.getElement(".spt_saved_search_input");
            var value = input.value;
            if (!value) {
                spt.alert("Please select a saved search to remove.");
                return;
            }

            spt.alert("Remove: " + value);



            '''
        } )
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:search_wdg.py

示例15: get_display

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


        web = WebContainer.get_web()
        palette = web.get_palette()

        widget = DivWdg()
        widget.add_style("width: 100%")
        widget.add_style("text-align: center")

        from tactic.ui.app import PageHeaderWdg
        header = PageHeaderWdg(show_project=False)
        widget.add( header )

        security = Environment.get_security()


        search = Search("sthpw/project")
        search.add_where("\"code\" not in ('sthpw', 'admin', 'unittest')")
        search.add_where("\"type\" not in ('resource')")
        # hide template projects
        if security.check_access("builtin", "view_site_admin", "allow") or security.check_access("builtin", "view_template_projects", "allow"):
            pass
        else:
            search.add_op("begin")
            search.add_filter("is_template", True, op='!=')
            search.add_filter("is_template", 'NULL', quoted=False, op='is')
            search.add_op("or")

        search.add_order_by("category")

        projects = search.get_sobjects()
        
        num = len(projects)
        # sort by project
        if num < 5:
            columns = 1
            icon_size = 90
            width = 500
        elif num < 15:
            columns = 2
            icon_size = 60
            width = 700
        else:
            columns = 3
            icon_size = 45
            width = 800

        div = DivWdg()

        div.add_style("margin-left: auto")
        div.add_style("margin-right: auto")
        #div.add_style("width: 520px")
        div.center()
        widget.add(div)

        #logo = TacticLogoWdg()
        #div.add(logo)
        div.add("<br/>"*3)

        bg_color = palette.color("background")
        #div.add_color("color", "color")

        from tactic.ui.container import RoundedCornerDivWdg
        div = RoundedCornerDivWdg(hex_color_code=bg_color,corner_size="10")
        div.set_dimensions( width_str='%spx' % width, content_height_str='50px' )
        div.add_border()
        div.add_style("overflow: hidden")
        div.set_box_shadow()

        div.add_style("margin-left: auto")
        div.add_style("margin-right: auto")
        div.add_style("width: %spx" % width)
        table = Table()
        table.set_max_width()
        table.add_style("margin-left: auto")
        table.add_style("margin-right: auto")
        table.add_style("background-color: %s" % bg_color)
        table.add_color("color", "color")

        tr, td = table.add_row_cell()
        logo_div = DivWdg()
        logo_div.add_gradient("background", "background3", -5, -10)
        td.add(logo_div)
        logo = TacticLogoWdg()
        logo_div.add(logo)
        logo_div.add_style("margin: -6 -6 6 -6")


        app_name = WebContainer.get_web().get_app_name()
        security = Environment.get_security() 

        last_category = None
        has_category = False
        index = 0 

        # if TACTIC has not been set up, show the configuration page
        # FIXME: what is the requirement for is_installed?
        config_path = Config.get_config_path()
        if not os.path.exists(config_path):
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:index_wdg.py


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