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


Python Site.pop_site方法代码示例

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


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

示例1: execute

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

        if not self.login_name:
            self.login_name = self.kwargs.get('login');

        # invalidate the ticket
        security = Environment.get_security()
        ticket = security.get_ticket()

        if ticket == None:
            return


        login_name = ticket.get_value("login")
        print "Signing out: ", login_name

        # expire the ticket

        from pyasm.security import Site
        site = Site.get()
        if site:
            Site.set_site("default")

        try:
            from pyasm.search import Sql, DbContainer
            sql = DbContainer.get("sthpw")
            ticket.set_value("expiry", sql.get_timestamp_now(), quoted=False)
            ticket.commit()
        except:
            if site:
                Site.pop_site()
开发者ID:mincau,项目名称:TACTIC,代码行数:33,代码来源:sign_out_cmd.py

示例2: get_by_key

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import pop_site [as 别名]
    def get_by_key(cls, key, search_type=None):
        from pyasm.security import Site
        site = Site.get_site()
        Site.set_site( Site.get_first_site() )

        project = Project.get_project_code() 
        dict_key = '%s:%s' %(key, search_type)
       
        search = Search(cls.SEARCH_TYPE, project_code=project)
        search.add_filter("key", key)
        if search_type:
            search.add_filter("search_type", search_type)

        if Project.get_project_name() in ['admin', 'sthpw']:
            return None
        prod_setting = ProdSetting.get_by_search(search, dict_key)

        Site.pop_site()

        return prod_setting
开发者ID:jayvdb,项目名称:TACTIC,代码行数:22,代码来源:prod_setting.py

示例3: get_display

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import pop_site [as 别名]
    def get_display(self):
       
        top = self.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_border()
        top.add_class("spt_delete_project_tool_top")
        site = self.kwargs.get("site")
        set_site = self.kwargs.get("set_site")

        if set_site != False and site:
            Site.set_site(site)

        login = Environment.get_user_name()
        
        security = Environment.get_security()

        if not security.is_admin() and not security.is_in_group(self.delete_group):

            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Only Admin can delete projects")
            top.add_style("padding: 50px")
            top.add_style("text-align: center")
            if set_site and site:
                Site.pop_site()
            return top






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

        # check if delete permissions exist for this site and project
        security = Environment.get_security()
        if False and not security.check_access("project", project_code, "delete"):
            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Not permitted to delete this project")
            top.add_style("padding: 30px")
            top.add_style("text-align: center")
            top.add_style("margin: 50px 30px")
            top.add_border()
            top.add_color("background", "background3")
            return top


        


        if project_code:
            project = Project.get_by_code(project_code)
            if not project:
                top.add(IconWdg(icon=IconWdg.WARNING))
                top.add("No project [%s] exists in this database" % project_code)
                top.add_style("padding: 30px")
                top.add_style("text-align: center")
                top.add_style("margin: 50px 30px")
                top.add_border()
                top.add_color("background", "background3")
                return top
            search_key = project.get_search_key()
        else:
            search_key = self.kwargs.get("search_key")
            project = Search.get_by_search_key(search_key)
            if project:
                project_code = project.get_code()

       
           
        title_wdg = DivWdg()

        if project:
            top.add(title_wdg)
            title_wdg.add(IconWdg(icon=IconWdg.WARNING))
            title_wdg.add("Deleting Project: %s" % project.get_value("title") ) 
            title_wdg.add_color("background", "background", -5)
            title_wdg.add_style("padding: 5px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_style("font-size: 14px")


        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if not search_key:
            warning_msg = "Projects must be deleted individually"
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
            return top

        warning_msg = "Deleting a project will delete the database associated with this project.  All data and files will be lost.  Please consider carefully before proceeding."
        if warning_msg:
            warning_wdg = DivWdg(warning_msg, css='warning')
            content.add(warning_wdg)
            warning_wdg.add_style("margin: 20 10px")
            content.add("<br/>")

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

示例4: create_sobject_log

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import pop_site [as 别名]

#.........这里部分代码省略.........
        # log a reference to each sobject affected
        already_logged = {}
        xml = Xml()
        xml.read_string(transaction_data)
        nodes = xml.get_nodes("transaction/*")


        # list of sobjects not logged
        not_logged = set([
            'sthpw/transaction_log',
            'sthpw/clipboard',
            'sthpw/sobject_log',
            'sthpw/file',
            'sthpw/message',
            'sthpw/message_log',
        ])

        find_parent = set([
            'sthpw/snapshot',
            'sthpw/note',
            'sthpw/task'
        ])


        from pyasm.security import Site
        current_site = Site.get_site()


        for node in nodes:
            node_name = xml.get_node_name(node)
            if node_name == "sobject":
                search_type = Xml.get_attribute(node,"search_type")
                search_type_obj = SearchType.get(search_type)


                if search_type_obj.get_base_key() in not_logged:
                    continue


                search_id = Xml.get_attribute(node,"search_id")
                search_code = Xml.get_attribute(node,"search_code")
                site = Xml.get_attribute(node,"site")


                if search_code:
                    search_key = "%s?code=%s" % (search_type, search_code)
                else:
                    search_key = "%s|%s" % (search_type, search_id)


                if already_logged.get(search_key):
                    continue
                already_logged[search_key] = True

                # delete items are not presently logged ...
                # TODO: maybe they should be
                action = Xml.get_attribute(node,"action")
                if action == "delete":
                    continue


                has_site = False
                if site:
                    try:
                        Site.set_site(site)
                        has_site = True
                    except:
                        print "Site [%s] does not exist" % site
                        continue


                try:

                    if search_code:
                        sobject = Search.get_by_code(search_type, search_code)
                    else:
                        sobject = Search.get_by_id(search_type, search_id)


                    if sobject:
                        SObjectLog.create(sobject, log, action)
                    else:
                        # record has been deleted
                        if search_code:
                            print("Skipped SObject log creation for [%s?code=%s]" %(search_type, search_code))
                        else:
                            print("Skipped SObject log creation for [%s|%s]" %(search_type, search_id))

                    if search_type_obj.get_base_key() in find_parent:
                        try:
                            if sobject:
                                sobject = sobject.get_parent()
                        except (SearchException, SqlException):
                            # don't worry if this parent can't be found.
                            pass
                        if sobject:
                            SObjectLog.create(sobject, log, "child_%s" % action)
                finally:
                    if has_site:
                        Site.pop_site()
开发者ID:mincau,项目名称:TACTIC,代码行数:104,代码来源:transaction_log.py


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