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


Python Project.get_global_project_code方法代码示例

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


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

示例1: execute

# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_global_project_code [as 别名]
    def execute(my):
        if not my.transaction_log:
            search = Search("sthpw/transaction_log")
            search.add_filter("type", "undo")

            # get the current project.  If the project is admin, then undo
            # works differently
            project = Project.get_global_project_code()
            assert project
            search.add_filter("namespace", project)

            user = Environment.get_user_name()
            assert user
            search.add_filter("login", user)

            search.add_order_by("timestamp desc")

            search.add_limit(1)
            my.transaction_log = search.get_sobject()

        if not my.transaction_log:
            print("WARNING: No transaction log found for undo")
            return CommandExitException()

        my.transaction_log.undo(ignore_files=my.ignore_files)

        my.transaction_log.set_value("type", "redo")
        my.transaction_log.commit()

        # undo triggers a special sync
        # if this is a sync undo, then do not propgate remote undos
        if not my.is_sync:
            my.transaction_log.trigger_remote_undo()
开发者ID:blezek,项目名称:TACTIC,代码行数:35,代码来源:undo_cmd.py

示例2: create

# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_global_project_code [as 别名]
    def create(cls, command, transaction_data, description, title='', state=None, keywords=None):
        user_name = Environment.get_user_name()
        #namespace = Environment.get_env_object().get_context_name()
        from pyasm.biz import Project
        namespace = Project.get_global_project_code()

        # TODO: need to add a ticket column to the transaction_log table
        security = Environment.get_security()
        ticket = security.get_ticket_key()

        #transaction_data = transaction_data.replace("\\", "\\\\")

        length_before = len(transaction_data)
        cutoff = 10*1024
        if length_before > cutoff:
            import zlib, binascii
            transaction_data = Common.process_unicode_string(transaction_data)
            ztransaction_data = binascii.hexlify(zlib.compress(transaction_data))
            ztransaction_data = "zlib:%s" % ztransaction_data
            length_after = len(ztransaction_data)
            print "transaction log compress: ", "%s%%" % int(float(length_after)/float(length_before)*100), "[%s] to [%s]" % (length_before, length_after)
        else:
            ztransaction_data = transaction_data

        # a new entry deletes all redos for that user
        TransactionLog.delete_all_redo()


        log = SObjectFactory.create("sthpw/transaction_log")
        log.set_value("login", user_name)
        log.set_value("command", command)
        log.set_value("transaction", ztransaction_data)
        log.set_value("title", title)
        log.set_value("description", description)
        log.set_value("type", "undo")
        log.set_value("namespace", namespace)
        log.set_value("ticket", ticket)
        if state:
            log.set_value("state", state)

        if keywords:
            log.set_value("keywords", keywords)

        server = Config.get_value("install", "server")
        if server:
            log.set_value("server_code", server)

        log.commit(triggers=False)



        # FIXME:
        # only do an sobject log before the cutoff ... above this it gets
        # very slow.  Need a way of doing very fast inserts
        if length_before <= cutoff:
            cls.create_sobject_log(log, transaction_data)
        return log
开发者ID:mincau,项目名称:TACTIC,代码行数:59,代码来源:transaction_log.py

示例3: execute

# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_global_project_code [as 别名]
    def execute(self):
        import time
        start = time.time()

        security = Environment.get_security()
        ticket = security.get_ticket_key()

        if not self.transaction_log:
            search = Search("sthpw/transaction_log")
            search.add_filter("type", "redo")

            # get the current project
            project = Project.get_global_project_code()
            search.add_filter("namespace", project)

            user = Environment.get_user_name()
            search.add_filter("login", user)

            search.add_order_by("timestamp")
            search.add_limit(1)

            self.transaction_log = search.get_sobject()

        if not self.transaction_log:
            return CommandExitException()

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

        self.transaction_log.redo(ignore=self.ignore, base_dir=base_dir)
        self.transaction_log.set_value("type", "undo")
        self.transaction_log.commit()

        # get the transaction and set it to not record this transaction
        transaction = Transaction.get()
        transaction.set_record(False)

        # update the change timestamps
        transaction.update_change_timestamps(self.transaction_log)

        print "RedoCmd: ", time.time() - start
        print
开发者ID:mincau,项目名称:TACTIC,代码行数:43,代码来源:undo_cmd.py

示例4: get_by_search_type

# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_global_project_code [as 别名]
    def get_by_search_type(search_type_obj, database):

        search_type = search_type_obj.get_base_key()

        # This is here to prevent an infinite loop
        if search_type == "sthpw/search_object":
            return

        if search_type == None:
            search_type = "sthpw/search_object"
            

        # if it already exists, then get the cached data
        cache_name = "SObjectConfig:sobject_configs_list"
        config_list = Container.get(cache_name)
        if config_list == None:
            config_list = {}
            Container.put(cache_name, config_list)

        if config_list.has_key(search_type):
            return config_list[search_type]


        # get the real search_type implementation to find the paths
        tmp = search_type.split("/")
        if len(tmp) == 2:
            sub_dir = tmp[0]
            search_key = tmp[1]
        else:
            sub_dir = tmp[0]
            search_key = tmp[2]

        filename = "%s-conf.xml" % search_key

        config = None


        # start with the site directory for overrides
        env = Environment.get_env_object()
        site_dir = env.get_site_dir()


        # This assumes that the context and the database are the same
        #context = search_type_obj.get_database()
        context = database
        # build up the file path and load in the config file
        if context == "sthpw":
            #from search import SearchType
            #project = SearchType.get_global_project()
            from pyasm.biz import Project
            project_code = Project.get_global_project_code()
            conf_path = "%s/sites/%s/config/sthpw/sobject/%s" \
                % (site_dir,project_code,filename)
        else:
            conf_path = "%s/sites/%s/config/sobject/%s" \
                % (site_dir,context,filename)


        if os.path.exists(conf_path):
            # load in the config path
            config = SObjectConfig( conf_path );

        else:

            # build the path from the site directory
            env = Environment.get_env_object()
            site_dir = env.get_site_dir()
            conf_path = "%s/sites/%s/config/sobject/%s" \
                % (site_dir,sub_dir,filename)


        if os.path.exists(conf_path):
            # load in config file
            config = SObjectConfig( conf_path );

        else:
            base_dir = Environment.get_install_dir()
            conf_path = "%s/src/config/%s/sobject/%s" \
                % (base_dir, sub_dir,  filename)

            if os.path.exists(conf_path):
                # load in config file
                config = SObjectConfig( conf_path );

    
        # store in container
        config_list[search_type] = config

        return config
开发者ID:0-T-0,项目名称:TACTIC,代码行数:91,代码来源:sobject_config.py

示例5: get_display

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

        #WebContainer.register_cmd("pyasm.admin.UndoLogCbk")

        # add a time filter
        div = DivWdg()
        div.add_color('background','background', -10)
        div.add_color('color','color')
        div.add_style("padding: 15px")
        div.add_border()
        project = ''
        # add a project filter
        if self.all_namespaces_flag:
            span = SpanWdg("Project: ")
            span.add_color('color','color')
            project_select = FilterSelectWdg("project")
            project_select.add_empty_option(label="-- All Projects --")
            project_select.set_option("query", "sthpw/project|code|title")
            span.add(project_select)
            div.add(span)

            project = project_select.get_value()
        else:
            from pyasm.biz import Project
            project = Project.get_global_project_code()


        # add a time filter
        from pyasm.prod.web import DateFilterWdg
        select = DateFilterWdg("undo_time_filter", label="Show Transaction Log From: ")
        select.set_label(["1 Hour Ago", "Today", "1 Day Ago", "1 Week Ago", "1 Month Ago"])
        select.set_value(["1 Hour", "today", "1 Day", "1 Week", "1 Month"])
        select.set_option("default", "1 Hour")
        div.add(select)

        time_interval = select.get_value() 

        self.add(div)

        if not self.all_users_flag:
            user = Environment.get_user_name()
        else:
            span = SpanWdg(css="med")
            span.add("User: ")
            user_select = FilterSelectWdg("user")
            user_select.set_option("query", "sthpw/login|login|login")
            user_select.add_empty_option()
            span.add(user_select)
            div.add(span)

            user = user_select.get_value()

        transaction_log = TransactionLog.get( user_name=user, \
            namespace=project, time_interval=time_interval)

        from tactic.ui.panel import FastTableLayoutWdg, TableLayoutWdg
        table = FastTableLayoutWdg(search_type="sthpw/transaction_log", view="table", show_shelf='false', show_select="false")
        #table = TableLayoutWdg(search_type="sthpw/transaction_log", view="table", mode='simple', show_row_select="false")
        table.set_sobjects(transaction_log)
        #table.set_refresh_mode("table")
        self.add(table)

        return super(UndoLogWdg, self).get_display()
开发者ID:mincau,项目名称:TACTIC,代码行数:65,代码来源:undo_log_wdg.py


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