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


Python security.Site类代码示例

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


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

示例1: get_db_resource_by_search_type

    def get_db_resource_by_search_type(cls, search_type):
        if search_type.startswith('sthpw/'):
            # get the local db_resource
            from pyasm.security import Site
            site = Site.get_site()
            db_resource = None
            if site:
                db_resource = Site.get_db_resource(site, "sthpw")
            if not db_resource:
                db_resource = DbResource.get_default("sthpw")
            return db_resource


        project_code = cls.get_database_by_search_type(search_type)
        project = Project.get_by_code(project_code)
        if not project:
            raise Exception("Error: Project [%s] does not exist" % project_code)


        if search_type.startswith("salesforce/"):
            db_resource_code = "Salesforce"
            db_resource = DbResource.get_by_code(db_resource_code, project_code)
            return db_resource


        db_resource = project.get_project_db_resource()

        return db_resource
开发者ID:mincau,项目名称:TACTIC,代码行数:28,代码来源:project.py

示例2: _do_execute

    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,代码行数:7,代码来源:scheduler.py

示例3: execute

    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,代码行数:31,代码来源:sign_out_cmd.py

示例4: error_page

    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,代码行数:52,代码来源:cherrypy30_startup.py

示例5: get_default_project

 def get_default_project(cls):
     from pyasm.security import Site
     project = Site.get().get_default_project()
     if project:
         return project
     project = Config.get_value("install", "default_project")
     return project
开发者ID:jayvdb,项目名称:TACTIC,代码行数:7,代码来源:project.py

示例6: execute

    def execute(my):
        if my.mode == 'basic':
            return

        # cache sthpw tables definitions
        from pyasm.security import Site
        site = Site.get_site()
        if site:
            key = "%s:sthpw_column_info" % site
        else:
            key = "sthpw_column_info"

        data = CacheContainer.get(key)
        if data == None:
            tables = ['project', 'search_object', 'login', 'login_group', 'login_in_group','snapshot','file','trigger','notification','ticket']
            kwargs = {
                "key": key,
                "database": 'sthpw',
                "tables": tables,
            }
            cache = TableInfoCache( **kwargs )



        # cache search object table
        search_type_cache = SearchTypeCache.get("sthpw/search_object")
        search_type_cache.build_cache_by_column("search_type")

        # cache login table
        search_type_cache = SearchTypeCache.get("sthpw/login")
        search_type_cache.build_cache_by_column("login")

        # cache login_group table
        search_type_cache = SearchTypeCache.get("sthpw/login_group")
        search_type_cache.build_cache_by_column("login_group")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:35,代码来源:cache_startup.py

示例7: get_site_root

    def get_site_root(self):
        from pyasm.security import Site
        site = Site.get().get_site_root()
        if site:
            return site

        return "tactic"
开发者ID:mincau,项目名称:TACTIC,代码行数:7,代码来源:web_environment.py

示例8: get_asset_dir

    def get_asset_dir(cls, file_object=None, alias=None):
        '''get base asset directory'''

        if file_object:
            alias = file_object.get_value('base_dir_alias')

        if not alias:
            alias = "default"


        from pyasm.security import Site
        asset_dir = Site.get().get_asset_dir(file_object=file_object,alias=alias)
        if asset_dir:
            return asset_dir


        alias_dict = cls.get_asset_dirs()
        asset_dir = alias_dict.get(alias)

        if not asset_dir:
            data_dir = Environment.get_data_dir()
            if data_dir:
                asset_dir = "%s/assets" % data_dir


        return asset_dir
开发者ID:mincau,项目名称:TACTIC,代码行数:26,代码来源:environment.py

示例9: get_db_triggers

    def get_db_triggers(cls):

        site_triggers = Container.get(cls.KEY)
        if site_triggers == None:
            # find all of the triggers
            search = Search("sthpw/trigger")
            search.add_project_filter()
            site_triggers = search.get_sobjects()
            Container.put(cls.KEY, site_triggers)

        # find all of the project triggers
        from pyasm.biz import Project
        site = Site.get_site()
        project_code = Project.get_project_code()
        key = "%s:%s:%s" % (cls.KEY, project_code, site)
        project_triggers = Container.get(key)
        if project_triggers == None:
            if project_code not in ['admin','sthpw']:
                try:
                    search = Search("config/trigger")
                    project_triggers = search.get_sobjects()
                except SearchException as e:
                    print("WARNING: ", e)
                    project_triggers = []
            else:
                project_triggers = []
            Container.put(key, project_triggers)

        triggers = []
        triggers.extend(site_triggers)
        triggers.extend(project_triggers)
        return triggers
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:trigger.py

示例10: set_project

    def set_project(cls, project_code):
        '''This is kept here because everybody is used to using this'''

        security = Environment.get_security()
        # FIXME:
        # Because it is possible to call this before one is 
        # logged in.  This is required to see the login screen.
        from pyasm.security import get_security_version
        security_version = get_security_version()
        if security_version != 1 and not project_code == 'admin':
            key = { 'code': project_code }
            key2 = { 'code': "*" }
            keys = [key, key2]
            if not security.check_access("project", keys, access="allow", default="deny"):
                user = Environment.get_login()
                if user:
                    user = user.get_value("login")
                    raise SecurityException("User [%s] is not permitted to view project [%s]" % (user, project_code))
                else:
                    raise SecurityException("User is not permitted to view project [%s]" % (project_code))

        from pyasm.security import Site
        site = Site.get_site()
        PROJECT_KEY = "Project:global:%s:" % site
        Container.put(PROJECT_KEY, project_code)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:25,代码来源:project.py

示例11: get_display

    def get_display(self):

        web = WebContainer.get_web()
        response = web.get_response()

        # get info from url
        site_obj = Site.get()
        path = web.get_request_path()
        path_info = site_obj.break_up_request_path(path)
        site = path_info.get("site")
        project_code = path_info.get("project_code")


        # find the relative path
        hash = self.kwargs.get("hash")
        parts = hash[1:]
        rel_path = "/".join(parts)

        #rel_path = "asset/Fantasy/Castle/54d45150c61251f65687d716cc3951f1_v001.jpg"


        # construct all of the paths
        asset_dir = web.get_asset_dir()
        base_dir = "%s/%s" % (asset_dir, project_code)
        path = "%s/%s" % (base_dir, rel_path)
        filename = os.path.basename(rel_path)

        print "path: ", path



        # determine the mimetype automatically
        import mimetypes
        base, ext = os.path.splitext(path)
        ext = ext.lower()
        mimetype = mimetypes.types_map[ext]

        headers = response.headers
        response.headers['Content-Type'] = mimetype

        response.headers['Content-Disposition'] = 'inline; filename={0}'.format(filename)

        use_xsendfile = True
        if use_xsendfile:
            response.headers['X-Sendfile'] = path
            return Widget(path)

        else:

            response.headers['Content-Transfer-Encoding'] = 'BINARY'

            widget = Widget()
            f = open(path, 'rb')
            data = f.read()
            f.close()

            widget.add(data)
            return widget
开发者ID:mincau,项目名称:TACTIC,代码行数:58,代码来源:top_wdg.py

示例12: clear_db_cache

    def clear_db_cache(cls):
        Container.put(cls.KEY, None)

        site = Site.get_site()

        from pyasm.biz import Project
        project_code = Project.get_project_code()
        key = "%s:%s:%s" % (cls.KEY, project_code, site)
        Container.put(key, None)
开发者ID:mincau,项目名称:TACTIC,代码行数:9,代码来源:trigger.py

示例13: get_global_project_code

 def get_global_project_code(cls):
     from pyasm.security import Site
     site = Site.get_site()
     PROJECT_KEY = "Project:global:%s:" % site
     project_code = Container.get(PROJECT_KEY)
     if not project_code:
         project_code = "admin"
         Project.set_global_project_code(project_code)
     return project_code
开发者ID:0-T-0,项目名称:TACTIC,代码行数:9,代码来源:project.py

示例14: get_display

    def get_display(my):

        top = DivWdg()

        hash = my.kwargs.get("hash")
        Container.put("url_hash", hash)

        security = Environment.get_security()
        is_admin = security.check_access("builtin", "view_site_admin", "allow")
        if hash == "/admin" and not is_admin:
            hash = "/index"

        if not hash:
            # NOTE: this really doesn't get call anymore because an empty
            # hash gets remapped to "/index"
            widget = my.get_default_wdg()
            top.add(widget)

        # This would provide a way to get the default index widget.
        #elif hash == "/projects":
        #    widget = my.get_default_wdg()
        #    from tactic_sites.default.modules import IndexWdg
        #    top.add( IndexWdg() )
        else:
            from tactic.ui.panel import HashPanelWdg

            project_code = Project.get_project_code()
            if project_code == 'admin' and hash == '/index':
                widget = my.get_default_wdg()

            else:
                print "HASH: ", hash
                print "project: ", project_code
                from pyasm.security import Site
                print "site: ", Site.get_site()
                widget = HashPanelWdg.get_widget_from_hash(hash, return_none=True)

            if not widget:
                if hash == "/index":
                    widget = my.get_default_wdg()
                elif hash == '/admin':
                    widget = my.get_default_wdg()
                else:
                    widget = HashPanelWdg.get_widget_from_hash("/index", return_none=True)


            top.add(widget)


        return top
开发者ID:asmboom,项目名称:TACTIC,代码行数:50,代码来源:top_container_wdg.py

示例15: __init__

    def __init__(my, **kwargs):
        my.kwargs = kwargs
        user = my.kwargs.get('user')
        project = my.kwargs.get('project')

        my.site = my.kwargs.get('site')
        if not my.site:
            # if not explicitly set, keep the site that is current
            my.site = Site.get_site()

        if user and project:
            from pyasm.security import Batch
            Batch(site=my.site, login_code=user, project_code=project)

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


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