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


Python Site.set_site方法代码示例

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


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

示例1: _do_execute

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import set_site [as 别名]
    def _do_execute(my):
        # restablish the site
        if my.site:
            Site.set_site(my.site)

        Environment.set_security(my.security)
        my.execute()
开发者ID:asmboom,项目名称:TACTIC,代码行数:9,代码来源:scheduler.py

示例2: execute

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import set_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

示例3: error_page

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import set_site [as 别名]
    def error_page(my, status, message, traceback, version):

        # check if this project exists
        response = cherrypy.response
        request = cherrypy.request
        path = request.path_info

        parts = path.split("/")
        if len(parts) < 3:
            cherrypy.response.body = '<meta http-equiv="refresh" content="0;url=/tactic" />'
            return 

        from pyasm.security import Site
        site_obj = Site.get()
        path_info = site_obj.break_up_request_path(path)

        if path_info:
            site = path_info['site']
            project_code = path_info['project_code']
        else:
            project_code = parts[2]
            site = ""


        # sites is already mapped in config for cherrypy
        if site == "plugins":
            return

        print "WARNING:"
        print "    status: ", status
        print "    message: ", message
        print "    site: ", site
        print "    project_code: ", project_code



        # Dump out the error
        has_site = False
        try:
            from pyasm.security import TacticInit
            TacticInit()

            Site.set_site(site)
            if site:
                eval("cherrypy.root.tactic.%s.%s" % (site, project_code))
            else:
                eval("cherrypy.root.tactic.%s" % project_code)
        # if project_code is empty , it raises SyntaxError
        except (AttributeError, SyntaxError), e:
            print "WARNING: ", e
            has_project = False
            has_site = True
开发者ID:asmboom,项目名称:TACTIC,代码行数:54,代码来源:cherrypy30_startup.py

示例4: get_by_key

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import set_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

示例5: get_display

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import set_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

示例6: set

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

        # make sure the appropriate site is set (based on the ticket)
        from pyasm.security import Site
        cookie = cherrypy.request.cookie
        if cookie.has_key("login_ticket"):
            cookie = cookie["login_ticket"].value
            site = Site.get().get_by_ticket(cookie)
        else:
            html_response = '''<html>
            <head><meta http-equiv="Refresh" content="0; url=/"></head>
            </html>'''
            response.body = ''
            return html_response

        Site.set_site(site)


        # if the url does not exist, but the project does, then check to
        # to see if cherrypy knows about it
        project = Project.get_by_code(project_code)
        if not has_project and project and project.get_value("type") != 'resource':

            print "register ..."

            startup = cherrypy.startup
            config = startup.config
            startup.register_site(project_code, config)
            #cherrypy.config.update( config )
            # give some time to refresh
            import time
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:33,代码来源:cherrypy30_startup.py

示例7: get_display

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

        top = my.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")

        login = Environment.get_user_name()
        if login != 'admin':
            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Only Admin can delete projects")
            top.add_style("padding: 50px")
            top.add_style("text-align: center")
            return top



        site = my.kwargs.get("site")
        if site:
            Site.set_site(site)



        project_code = my.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 = my.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/>")

        
        if not project_code:
            content.add("This project [%s] has been deleted."%search_key)
            return top
        elif not project:
            content.add("This project [%s] has been deleted."%project_code)
            return top

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

示例8: create_sobject_log

# 需要导入模块: from pyasm.security import Site [as 别名]
# 或者: from pyasm.security.Site import set_site [as 别名]
    def create_sobject_log(cls, log, transaction_data=None):

        if not transaction_data:
            transaction_data = log.get_value("transaction")

        # 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
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:transaction_log.py


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